Class: Commands::Configs
- Inherits:
-
Object
- Object
- Commands::Configs
- Defined in:
- lib/commands/configs.rb
Instance Method Summary collapse
-
#options ⇒ Object
holds the options that were passed you can set any initial defaults here.
- #register(opts, global_options) ⇒ Object
-
#required_options ⇒ Object
required options.
- #run(global_options) ⇒ Object
Instance Method Details
#options ⇒ Object
holds the options that were passed you can set any initial defaults here
13 14 15 16 |
# File 'lib/commands/configs.rb', line 13 def @options ||= { } end |
#register(opts, global_options) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/commands/configs.rb', line 24 def register(opts, ) opts. = "Usage: configs" opts.description = "List all configurations." opts.on('-r', "--config-repo name", EbmSharedLib::REPO_COMMAND_DETAILS) do |v| [:config_repo] = v end end |
#required_options ⇒ Object
required options
19 20 21 22 |
# File 'lib/commands/configs.rb', line 19 def @required_options ||= Set.new [ ] end |
#run(global_options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/commands/configs.rb', line 34 def run() # show contents of configs directory for files with .config extension # try to make sure the repo is available config_repo = [:config_repo] repo_url = EbmSharedLib.prepare_config_repo(config_repo) config_path = EbmSharedLib.full_config_path(repo_url) config_names = Pathname.glob("#{config_path}/configs/*.config").map { |file_info| if file_info.directory? == false name = file_info.basename.to_s name.slice!("#{EbmSharedLib::CONFIG_SUFFIX}") name else nil end } puts "\nCurrent configurations for #{repo_url}:" config_names.each do |name| puts name unless name.nil? end end |