diff options
| author | mo <mo.khan@gmail.com> | 2018-03-18 14:49:10 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2018-03-18 14:49:10 -0600 |
| commit | 2ed4e10db248704346c490f7ffc5d913f2985ef6 (patch) | |
| tree | cb9414ca66a89c8b4750834097b8e6274a5dc366 /lib | |
| parent | 0878dc92feebe759244cbed5f93c75012b8d84ac (diff) | |
add setup command to generate a new .atsrc.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ats/cli.rb | 27 | ||||
| -rw-r--r-- | lib/ats/configuration.rb | 2 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/ats/cli.rb b/lib/ats/cli.rb index 39e6ae1..27df34f 100644 --- a/lib/ats/cli.rb +++ b/lib/ats/cli.rb @@ -15,6 +15,33 @@ module ATS def version say ATS::VERSION end + + desc 'setup', 'Initialize the .atsrc file.' + def setup(configuration = ATS.configuration) + say "Current Configuration:", :green + say JSON.pretty_generate(configuration.configuration), :green + + configuration.config_files.each do |file| + if File.exist?(file) + say "Found #{file}. Nothing to do. Good bye!", :green + exit 0 + end + end + + say "Configuration file not found." + new_file = configuration.config_files.first + say "New file created at #{new_file}." + yaml = YAML.dump({ + default: { + threat_grid: { + api_host: 'https://example.com', + api_key: 'secret' + } + } + }) + say yaml, :yellow + IO.write(new_file, yaml) + end end end end diff --git a/lib/ats/configuration.rb b/lib/ats/configuration.rb index 30989bf..66ebe27 100644 --- a/lib/ats/configuration.rb +++ b/lib/ats/configuration.rb @@ -1,6 +1,6 @@ module ATS class Configuration - attr_accessor :logger, :config_files + attr_accessor :logger, :config_files, :configuration def initialize @logger = Logger.new(STDOUT) |
