Class: GLI::InitConfig
- Inherits:
-
Command
- Object
- CommandLineToken
- Command
- GLI::InitConfig
- Defined in:
- lib/gli/commands/initconfig.rb
Overview
Command that initializes the configuration file for apps that use it.
Constant Summary collapse
- COMMANDS_KEY =
:nodoc:
'commands'
Constants inherited from Command
Instance Attribute Summary
Attributes included from CommandSupport
Attributes inherited from CommandLineToken
#aliases, #description, #long_description, #name
Instance Method Summary collapse
-
#initialize(config_file_name, commands, flags, switches) ⇒ InitConfig
constructor
A new instance of InitConfig.
Methods inherited from Command
#action, #default_command, #default_desc, #has_option?, name_as_string, #name_for_help
Methods included from CommandSupport
#arg_name, #arguments_description, #arguments_options, #commands, #commands_declaration_order, #context_description, #default_description, #default_value, #desc, #execute, #flag, #flags, #get_default_command, #has_action?, #long_desc, #names, #nodoc, #skips_around, #skips_post, #skips_pre, #switch, #switches, #topmost_ancestor
Methods included from DSL
#arg_name, #clear_nexts, #command, #default_value, #desc, #flag, #flags_declaration_order, #long_desc, #switch, #switches_declaration_order
Methods inherited from CommandLineToken
Constructor Details
#initialize(config_file_name, commands, flags, switches) ⇒ InitConfig
Returns a new instance of InitConfig.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gli/commands/initconfig.rb', line 11 def initialize(config_file_name,commands,flags,switches) @filename = config_file_name super(:names => :initconfig, :description => "Initialize the config file using current global options", :long_desc => 'Initializes a configuration file where you can set default options for command line flags, both globally and on a per-command basis. These defaults override the built-in defaults and allow you to omit commonly-used command line flags when invoking this program', :skips_pre => true,:skips_post => true, :skips_around => true) @app_commands = commands @app_flags = flags @app_switches = switches self.desc 'force overwrite of existing config file' self.switch :force action do |,,arguments| if [:force] || !File.exist?(@filename) create_config(,,arguments) else raise "Not overwriting existing config file #{@filename}, use --force to override" end end end |