Class: Teems::CLI
Overview
Command-line interface entry point that dispatches to commands
Constant Summary collapse
- ERROR_LABELS =
{ AuthError => 'Auth error', ApiError => 'API error' }.freeze
- COMMANDS =
{ 'activity' => Commands::Activity, 'auth' => Commands::Auth, 'cal' => Commands::Cal, 'channels' => Commands::Channels, 'chats' => Commands::Chats, 'meeting' => Commands::Meeting, 'messages' => Commands::Messages, 'sync' => Commands::Sync, 'who' => Commands::Who, 'org' => Commands::Org, 'ooo' => Commands::Ooo, 'status' => Commands::Status, 'help' => Commands::Help }.freeze
Instance Method Summary collapse
-
#initialize(argv, output: Formatters::Output.new, runner: nil) ⇒ CLI
constructor
A new instance of CLI.
- #route_command(command_name, args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv, output: Formatters::Output.new, runner: nil) ⇒ CLI
Returns a new instance of CLI.
60 61 62 63 64 |
# File 'lib/teems/cli.rb', line 60 def initialize(argv, output: Formatters::Output.new, runner: nil) @argv = argv.dup @output = output @runner_override = runner end |
Instance Method Details
#route_command(command_name, args) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/teems/cli.rb', line 75 def route_command(command_name, args) return show_help if help_requested? return show_version if version_requested? dispatch_command(command_name, args) end |
#run ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/teems/cli.rb', line 66 def run command_name, *args = @argv route_command(command_name, args) rescue Interrupt handle_interrupt rescue StandardError => e handle_error(e) end |