Class: FjordBootCamp::CLI
- Inherits:
-
Thor
- Object
- Thor
- FjordBootCamp::CLI
- Defined in:
- lib/fjord_boot_camp/cli.rb
Instance Method Summary collapse
- #practices(subcommand = 'list', id = nil) ⇒ Object
- #progress ⇒ Object
- #reports(subcommand = 'list', id = nil) ⇒ Object
- #users(subcommand = 'list', id = nil) ⇒ Object
- #version ⇒ Object
Instance Method Details
#practices(subcommand = 'list', id = nil) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fjord_boot_camp/cli.rb', line 70 def practices(subcommand = 'list', id = nil) case subcommand when 'list' data = client.practices.list json_output? ? puts(JSON.pretty_generate(data)) : print_practices(data['practices'] || data) when 'show' abort 'Usage: fjord_boot_camp practices show ID' unless id data = client.practices.find(id) puts JSON.pretty_generate(data) else abort "Unknown subcommand: #{subcommand}. Use: list, show" end end |
#progress ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/fjord_boot_camp/cli.rb', line 87 def progress data = client.trainee_progresses.list( week_start: [:week_start], company_id: [:company_id] ) json_output? ? puts(JSON.pretty_generate(data)) : print_progress_report(data) end |
#reports(subcommand = 'list', id = nil) ⇒ Object
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 41 42 43 |
# File 'lib/fjord_boot_camp/cli.rb', line 16 def reports(subcommand = 'list', id = nil) case subcommand when 'list' data = client.reports.list( user_id: [:user_id], limit: [:limit], page: [:page] ) if json_output? puts JSON.pretty_generate(data) else print_reports(data['reports'] || data) end when 'show' abort 'Usage: fjord_boot_camp reports show ID' unless id data = client.reports.find(id) json_output? ? puts(JSON.pretty_generate(data)) : print_report_detail(data) when 'recent' data = client.reports.recent if json_output? puts JSON.pretty_generate(data) else print_reports(data['reports'] || data) end else abort "Unknown subcommand: #{subcommand}. Use: list, show, recent" end end |
#users(subcommand = 'list', id = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fjord_boot_camp/cli.rb', line 48 def users(subcommand = 'list', id = nil) case subcommand when 'list' data = client.users.list(target: [:target], page: [:page]) if json_output? puts JSON.pretty_generate(data) else print_users(data['users'] || data) end when 'show' abort 'Usage: fjord_boot_camp users show ID' unless id data = client.users.find(id) json_output? ? puts(JSON.pretty_generate(data)) : print_user_detail(data) when 'trainees' data = client.users.trainees json_output? ? puts(JSON.pretty_generate(data)) : print_users(data['users'] || data) else abort "Unknown subcommand: #{subcommand}. Use: list, show, trainees" end end |
#version ⇒ Object
96 97 98 |
# File 'lib/fjord_boot_camp/cli.rb', line 96 def version puts "fjord_boot_camp #{FjordBootCamp::VERSION}" end |