Module: Zendesk::CommandLine

Extended by:
CommandLine
Included in:
CommandLine
Defined in:
lib/zendesk/command_line.rb

Instance Method Summary collapse

Instance Method Details

#runObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/zendesk/command_line.rb', line 14

def run
  opts = Slop.parse do |opts|
    opts.array '-f', '--files', 'json file paths to load e.g. Users.json', default: default_file_paths
    opts.string '-c', '--command', 'command expression e.g _id=101'

    opts.on '--version', 'print the version' do
      puts Zendesk::VERSION

      exit
    end
  end

  if opts[:command].blank?
    puts opts

    exit
  end

  results = Zendesk::Processor.process(opts[:command], opts[:files])

  Printer::Table.print(results)
end