Class: Glb::Command
Direct Known Subclasses
Class Method Summary collapse
- .alter_command_description(command) ⇒ Object
-
.command_help(shell, command_name) ⇒ Object
Override command_help to include the description at the top of the long_description.
- .dispatch(m, args, options, config) ⇒ Object
-
.exit_on_failure? ⇒ Boolean
github.com/erikhuda/thor/issues/244 Deprecation warning: Thor exit with status 0 on errors.
-
.website ⇒ Object
meant to be overriden.
Class Method Details
.alter_command_description(command) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/glb/command.rb', line 57 def alter_command_description(command) return unless command # Add description to beginning of long_description long_desc = if command.long_description "#{command.description}\n\n#{command.long_description}" else command.description end # add reference url to end of the long_description unless website.empty? full_command = [command.ancestor_name, command.name].compact.join('-') url = "#{website}/reference/glb-#{full_command}" long_desc += "\n\nHelp also available at: #{url}" end command.long_description = long_desc end |
.command_help(shell, command_name) ⇒ Object
Override command_help to include the description at the top of the long_description.
50 51 52 53 54 55 |
# File 'lib/glb/command.rb', line 50 def command_help(shell, command_name) meth = normalize_command_name(command_name) command = all_commands[meth] alter_command_description(command) super end |
.dispatch(m, args, options, config) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/glb/command.rb', line 21 def dispatch(m, args, , config) # Allow calling for help via: # glb command help # glb command -h # glb command --help # glb command -D # # as well thor's normal way: # # glb help command help_flags = Thor::HELP_MAPPINGS + ["help"] if args.length > 1 && !(args & help_flags).empty? args -= help_flags args.insert(-2, "help") end # glb version # glb --version # glb -v version_flags = ["--version", "-v"] if args.length == 1 && !(args & version_flags).empty? args = ["version"] end super end |
.exit_on_failure? ⇒ Boolean
github.com/erikhuda/thor/issues/244 Deprecation warning: Thor exit with status 0 on errors. To keep this behavior, you must define exit_on_failure? in Lono::CLI You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
86 87 88 |
# File 'lib/glb/command.rb', line 86 def exit_on_failure? true end |
.website ⇒ Object
meant to be overriden
79 80 81 |
# File 'lib/glb/command.rb', line 79 def website "" end |