Module: AwsReporting::Command::Run

Defined in:
lib/aws-reporting/command/run.rb

Constant Summary collapse

MESSAGE_ALREADY_EXIST =
" already exists. If you want to overwrite this, use '-f' option."
MESSAGE_NOT_CONFIGURED =
"Can not access config file. Run `aws-reporting config` command first."

Class Method Summary collapse

Class Method Details

.run(opts, args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/aws-reporting/command/run.rb', line 7

def run(opts, args)
  begin
    help = opts['h']
    if help
      puts opts.help
      return
    end

    force = opts['f']
    raise AwsReporting::Error::CommandArgumentError.new unless args.length == 1
    path = args[0]

    generator = AwsReporting::Generator.new
    generator.path = path
    generator.force = force
    generator.generate
  rescue AwsReporting::Error::CommandArgumentError
    puts opts.help
  rescue AwsReporting::Error::OverwriteError => e
    puts e.path + MESSAGE_ALREADY_EXIST
  rescue AwsReporting::Error::ConfigFileLoadError
    puts MESSAGE_NOT_CONFIGURED
  end
end