Class: Commands::Configs

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/configs.rb

Instance Method Summary collapse

Instance Method Details

#optionsObject

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
  @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, global_options)
  opts.banner = "Usage: configs"
  opts.description = "List all configurations."
    
  opts.on('-r', "--config-repo name", EbmSharedLib::REPO_COMMAND_DETAILS) do |v|
    options[:config_repo] = v
  end
end

#required_optionsObject

required options



19
20
21
22
# File 'lib/commands/configs.rb', line 19

def required_options
  @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(global_options)
  # show contents of configs directory for files with .config extension
  # try to make sure the repo is available
  config_repo = options[: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