Class: Sem4rCli::CommandReport

Inherits:
OptParseCommand::Command
  • Object
show all
Defined in:
lib/sem4r_cli/commands/cmd_report.rb

Overview

report (v13 api)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(common_args) ⇒ CommandReport

Returns a new instance of CommandReport.



42
43
44
45
# File 'lib/sem4r_cli/commands/cmd_report.rb', line 42

def initialize(common_args)
  @common_args = common_args
  @subcommands = %w{list download schedule}
end

Class Method Details

.commandObject



34
35
36
# File 'lib/sem4r_cli/commands/cmd_report.rb', line 34

def self.command
  "report"
end

.descriptionObject



38
39
40
# File 'lib/sem4r_cli/commands/cmd_report.rb', line 38

def self.description
  "manage v13 report"
end

Instance Method Details

#parse_and_run(argv) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/sem4r_cli/commands/cmd_report.rb', line 47

def parse_and_run(argv)
  options = OpenStruct.new
  rest    = command_opt_parser(options).parse(argv)
  return false if options.exit

  if rest.length == 0
    puts "missing sub command"
    return false
  end

  ret = true
  subcommand = rest[0]
  subcommand_args = rest[1..-1]
  case subcommand
    when "list"
      Sem4rCli::report(@common_args..reports, :id, :name, :status)

    when "download"
      ret = download(subcommand_args)

    when "schedule"
      ret = schedule(subcommand_args)

    else
      puts "unknow subcommand '#{subcommand}'; must be one of #{@subcomands.join(", ")}"
      return false
  end

  @common_args..adwords.p_counters
  ret
end