Class: Abt::Cli
- Inherits:
-
Object
- Object
- Abt::Cli
- Defined in:
- lib/abt/cli.rb,
lib/abt/cli/prompt.rb,
lib/abt/cli/global_commands.rb,
lib/abt/cli/arguments_parser.rb,
lib/abt/cli/global_commands/help.rb,
lib/abt/cli/global_commands/share.rb,
lib/abt/cli/global_commands/readme.rb,
lib/abt/cli/global_commands/version.rb,
lib/abt/cli/global_commands/commands.rb,
lib/abt/cli/global_commands/examples.rb
Overview
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Modules: GlobalCommands Classes: Abort, ArgumentsParser, Exit, Prompt
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#err_output ⇒ Object
readonly
Returns the value of attribute err_output.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
-
#remaining_args ⇒ Object
readonly
Returns the value of attribute remaining_args.
Instance Method Summary collapse
- #abort(message) ⇒ Object
- #aris ⇒ Object
- #directory_config ⇒ Object
- #exit_with_message(message) ⇒ Object
-
#initialize(argv: ARGV, input: $stdin, output: $stdout, err_output: $stderr) ⇒ Cli
constructor
A new instance of Cli.
- #perform ⇒ Object
- #print(*args) ⇒ Object
- #print_ari(scheme, path, description = nil) ⇒ Object
- #puts(*args) ⇒ Object
- #warn(*args) ⇒ Object
Constructor Details
#initialize(argv: ARGV, input: $stdin, output: $stdout, err_output: $stderr) ⇒ Cli
Returns a new instance of Cli.
15 16 17 18 19 20 21 |
# File 'lib/abt/cli.rb', line 15 def initialize(argv: ARGV, input: $stdin, output: $stdout, err_output: $stderr) (@command, *@remaining_args) = argv @input = input @output = output @err_output = err_output @prompt = Abt::Cli::Prompt.new(output: err_output) end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
13 14 15 |
# File 'lib/abt/cli.rb', line 13 def command @command end |
#err_output ⇒ Object (readonly)
Returns the value of attribute err_output.
13 14 15 |
# File 'lib/abt/cli.rb', line 13 def err_output @err_output end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
13 14 15 |
# File 'lib/abt/cli.rb', line 13 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
13 14 15 |
# File 'lib/abt/cli.rb', line 13 def output @output end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
13 14 15 |
# File 'lib/abt/cli.rb', line 13 def prompt @prompt end |
#remaining_args ⇒ Object (readonly)
Returns the value of attribute remaining_args.
13 14 15 |
# File 'lib/abt/cli.rb', line 13 def remaining_args @remaining_args end |
Instance Method Details
#aris ⇒ Object
61 62 63 |
# File 'lib/abt/cli.rb', line 61 def aris @aris ||= ArgumentsParser.new(sanitized_piped_args + remaining_args).parse end |
#directory_config ⇒ Object
65 66 67 |
# File 'lib/abt/cli.rb', line 65 def directory_config @directory_config ||= Abt::DirectoryConfig.new end |
#exit_with_message(message) ⇒ Object
57 58 59 |
# File 'lib/abt/cli.rb', line 57 def () raise Exit, end |
#perform ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/abt/cli.rb', line 23 def perform if command.nil? warn("No command specified, printing help\n\n") @command = "help" end return process_alias if alias? return process_global_command if global_command? process_aris end |
#print(*args) ⇒ Object
49 50 51 |
# File 'lib/abt/cli.rb', line 49 def print(*args) output.print(*args) end |
#print_ari(scheme, path, description = nil) ⇒ Object
35 36 37 38 39 |
# File 'lib/abt/cli.rb', line 35 def print_ari(scheme, path, description = nil) command = "#{scheme}:#{path}" command += " # #{description}" unless description.nil? output.puts command end |
#puts(*args) ⇒ Object
45 46 47 |
# File 'lib/abt/cli.rb', line 45 def puts(*args) output.puts(*args) end |
#warn(*args) ⇒ Object
41 42 43 |
# File 'lib/abt/cli.rb', line 41 def warn(*args) err_output.puts(*args) end |