Class: Idonethis::Adapters::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/adapters/cli.rb

Class Method Summary collapse

Class Method Details

.run(argv = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/adapters/cli.rb', line 11

def run(argv={})
  args = parse(argv)

  command,*rest = argv

  command = "help" unless command
  
  log = choose_log(args) 
  
  args.merge!({ opts: rest, log: log, internet: Idonethis::Adapters::Internet, view: Idonethis::Adapters::Views::Cli::List.method(:apply)})
  credential = Settings.credential 

  log.call "args: #{args}, command: #{command}, rest: #{rest}"
  
  use_case = choose command.to_sym, rest

  unless use_case
    log.call "No command <#{command.to_sym}> found"
    return
  end

  use_case.call credential, args
end