Class: YleTfPlugins::CommandHelp::Command
- Inherits:
-
Object
- Object
- YleTfPlugins::CommandHelp::Command
- Defined in:
- lib/yle_tf_plugins/commands/help/command.rb
Instance Method Summary collapse
- #device(env) ⇒ Object
-
#error?(env) ⇒ Boolean
rubocop:enable Metrics/AbcSize, Metrics/MethodLength.
- #execute(env) ⇒ Object
-
#opts ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
- #tf_command_help ⇒ Object
Instance Method Details
#device(env) ⇒ Object
41 42 43 |
# File 'lib/yle_tf_plugins/commands/help/command.rb', line 41 def device(env) error?(env) ? STDERR : STDOUT end |
#error?(env) ⇒ Boolean
rubocop:enable Metrics/AbcSize, Metrics/MethodLength
37 38 39 |
# File 'lib/yle_tf_plugins/commands/help/command.rb', line 37 def error?(env) env[:tf_env] == 'error' end |
#execute(env) ⇒ Object
10 11 12 13 |
# File 'lib/yle_tf_plugins/commands/help/command.rb', line 10 def execute(env) device(env).puts(opts.help) exit 1 if error?(env) end |
#opts ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/yle_tf_plugins/commands/help/command.rb', line 16 def opts OptionParser.new do |o| o.summary_width = 18 o. = 'Usage: tf <environment> <command> [<args>]' o.separator '' o.separator 'YleTf options:' o.on('-h', '--help', 'Prints this help') o.on('-v', '--version', 'Prints the version information') o.on('--debug', 'Print debug information') o.on('--no-color', 'Do not output with colors') o.on('--no-hooks', 'Do not run any hooks') o.on('--only-hooks', 'Only run the hooks') o.separator '' o.separator 'Special YleTf commands:' o.separator tf_command_help o.separator '' o.separator 'Run `terraform -help` to get list of all Terraform commands.' end end |
#tf_command_help ⇒ Object
45 46 47 48 49 |
# File 'lib/yle_tf_plugins/commands/help/command.rb', line 45 def tf_command_help YleTf::Plugin.manager.commands.sort.map do |command, data| " #{command.ljust(18)} #{data[:synopsis]}" end end |