lib/adapters/cli.rb in idonethis-cli-0.11.0 vs lib/adapters/cli.rb in idonethis-cli-0.12.0
- old
+ new
@@ -19,28 +19,38 @@
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 = choose command.to_sym, rest
- 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
private
+
+ def choose(command, opts)
+ 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" }
+ }
+
+ if command == :list && opts.include?("teams")
+ return ->(credential, args) {
+ Idonethis::UseCases::Teams.apply(credential, args.merge(view: Idonethis::Adapters::Views::Cli::Teams.method(:apply)))
+ }
+ end
+
+ use_case = use_cases[command]
+ end
def choose_log(args={})
args[:verbose] == true ? ->(msg){puts "[LOG] #{msg}"} : ->(_){}
end