Class: Hanami::CLI
- Inherits:
-
Object
- Object
- Hanami::CLI
- Defined in:
- lib/hanami/cli.rb,
lib/hanami/cli/usage.rb,
lib/hanami/cli/banner.rb,
lib/hanami/cli/option.rb,
lib/hanami/cli/parser.rb,
lib/hanami/cli/command.rb,
lib/hanami/cli/version.rb,
lib/hanami/cli/registry.rb,
lib/hanami/cli/program_name.rb,
lib/hanami/cli/command_registry.rb
Overview
General purpose Command Line Interface (CLI) framework for Ruby
Defined Under Namespace
Modules: Banner, Parser, ProgramName, Registry, Usage Classes: Argument, Command, CommandRegistry, Option
Constant Summary collapse
- VERSION =
"0.1.0".freeze
Class Method Summary collapse
-
.command?(command) ⇒ TrueClass, FalseClass
private
Check if command.
Instance Method Summary collapse
-
#call(arguments: ARGV, out: $stdout) ⇒ Object
Invoke the CLI.
-
#initialize(registry) ⇒ Hanami::CLI
constructor
Create a new instance.
Constructor Details
#initialize(registry) ⇒ Hanami::CLI
Create a new instance
39 40 41 |
# File 'lib/hanami/cli.rb', line 39 def initialize(registry) @commands = registry end |
Class Method Details
.command?(command) ⇒ TrueClass, FalseClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if command
24 25 26 27 28 29 30 31 |
# File 'lib/hanami/cli.rb', line 24 def self.command?(command) case command when Class command.ancestors.include?(Command) else command.is_a?(Command) end end |
Instance Method Details
#call(arguments: ARGV, out: $stdout) ⇒ Object
Invoke the CLI
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/hanami/cli.rb', line 49 def call(arguments: ARGV, out: $stdout) result = commands.get(arguments) if result.found? command, args = parse(result, out) command.call(args) else usage(result, out) end end |