Skip to content

Commit 5dde116

Browse files
committed
feat(commands): add debug option as hidden
1 parent 70db789 commit 5dde116

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/commands/base.cr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ module Geode::Commands
33
def initialize
44
super
55

6+
@debug = false
67
@inherit_options = true
78
add_option "no-color", description: "disable ansi color formatting"
89
add_option 'h', "help", description: "get help information"
10+
add_option "debug", hidden: true
911
end
1012

1113
def help_template : String
1214
Commands.format_command self
1315
end
1416

1517
def pre_run(arguments : Cling::Arguments, options : Cling::Options) : Nil
18+
@debug = options.has? "debug"
1619
Colorize.enabled = false if options.has? "no-color"
1720
return unless options.has? "help"
1821

@@ -54,6 +57,11 @@ module Geode::Commands
5457
"https://github.com/devnote-dev/geode/issues"
5558
)
5659
end
60+
61+
if @debug
62+
info "Debug backtrace:"
63+
(ex.backtrace || %w[???]).each { |line| stdout << " " << line << '\n' }
64+
end
5765
end
5866

5967
def on_missing_arguments(args : Array(String))

src/commands/format.cr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module Geode::Commands
5252
max_size = 6 + command.options.keys.max_of &.size
5353

5454
command.options.each do |name, option|
55+
next if option.hidden?
5556
name_size = 2 + option.long.size
5657

5758
str << "» "

0 commit comments

Comments
 (0)