Sha256: 95a2b6a6f4fa394cf884f1b1c54d67b8019cfdf7f45278fd13b76c298344f30c
Contents?: true
Size: 1.55 KB
Versions: 5
Compression:
Stored size: 1.55 KB
Contents
require "thor" # Override thor's long_desc identation behavior # https://github.com/erikhuda/thor/issues/398 class Thor module Shell class Basic def print_wrapped(message, options = {}) message = "\n#{message}" unless message[0] == "\n" stdout.puts message end end end end module Lono class Command < Thor class << self def dispatch(m, args, options, config) # Allow calling for help via: # lono command help # lono command -h # lono command --help # lono command -D # # as well thor's normal way: # # lono help command help_flags = Thor::HELP_MAPPINGS + ["help"] if args.length > 1 && !(args & help_flags).empty? args -= help_flags args.insert(-2, "help") end # lono version # lono --version # lono -v version_flags = ["--version", "-v"] if args.length == 1 && !(args & version_flags).empty? args = ["version"] end super end # Override command_help to include the description at the top of the # long_description. def command_help(shell, command_name) meth = normalize_command_name(command_name) command = all_commands[meth] long_desc = if command.long_description "#{command.description}\n\n#{command.long_description}" else command.description end command.long_description = long_desc super end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
lono-4.0.5 | lib/lono/command.rb |
lono-4.0.4 | lib/lono/command.rb |
lono-4.0.3 | lib/lono/command.rb |
lono-4.0.2 | lib/lono/command.rb |
lono-4.0.1 | lib/lono/command.rb |