10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/adapters/cli.rb', line 10
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_cases = {
list: Idonethis::UseCases::List.method(:apply),
new: Idonethis::UseCases::New.method(:apply),
config: Idonethis::UseCases::Config.method(:apply),
git: Idonethis::UseCases::Git.method(:apply),
help: ->(credential, args) { puts "TODO: implement help" }
}
use_case = use_cases[command.to_sym]
unless use_case
puts "No command <#{command.to_sym}> found"
return
end
use_case.call credential, args
end
|