Module: Simple::CLI::Helper
- Extended by:
- Helper
- Included in:
- Helper
- Defined in:
- lib/simple/cli/helper.rb,
lib/simple/cli/helper/help.rb,
lib/simple/cli/helper/short_help.rb,
lib/simple/cli/helper/help_on_command.rb
Instance Method Summary collapse
- #help!(service, verbose:) ⇒ Object
- #help_on_command!(service, command, verbose:) ⇒ Object
- #short_help!(service) ⇒ Object
Instance Method Details
#help!(service, verbose:) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/simple/cli/helper/help.rb', line 3 def help!(service, verbose:) STDERR.puts " \#{H.binary_name} <subcommand> [ options... ]\n\n Subcommands:\n\n \#{format_usages usages(service, verbose: verbose), prefix: \" \"}\n\n Default options and subcommands include:\n\n \#{format_usages default_usages(service, verbose: verbose), prefix: \" \"}\n\n MSG\n\n exit 2\nend\n" |
#help_on_command!(service, command, verbose:) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/simple/cli/helper/help_on_command.rb', line 7 def help_on_command!(service, command, verbose:) _ = verbose action = H.action_for_command(service, command) parts = [ action.short_description, action_usage(action), action.full_description, ].compact STDERR.puts " \#{parts.join(\"\\n\\n\")}\n\n MSG\n\n exit 2\nend\n" |
#short_help!(service) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/simple/cli/helper/short_help.rb', line 5 def short_help!(service) # We check if we have only a few number of actions. In that case we just show the full help instead. actions = ::Simple::Service.actions(service).values actions, hidden_actions = actions.partition(&:short_description) STDERR.puts " \#{H.binary_name} <subcommand> [ options... ]\n\n MSG\n\n # if we don't have too many subcommands we print them here. If not, we only print their names\n # and mention the help command.\n if actions.count < 8\n STDERR.puts <<~MSG\n Subcommands:\n\n \#{format_usages usages(service, verbose: false), prefix: \" \"}\n\n MSG\n else\n subcommands = actions.map { |action| \"'\" + H.action_to_command(action.name) + \"'\" }\n msg = \"Subcommands include \#{subcommands.sort.join(\", \")}\"\n msg += \" (and, in addition, \#{hidden_actions.count} internal commands)\" if hidden_actions.count > 0\n\n STDERR.puts <<~MSG\n \#{msg}. Run with \"-h\" for more details.\n\n MSG\n end\n\n STDERR.puts <<~MSG\n Default options and subcommands include:\n\n \#{format_usages default_usages(service, verbose: false), prefix: \" \"}\n\n MSG\n\n exit 2\nend\n" |