Class: Psgc::CLI
- Inherits:
-
Object
- Object
- Psgc::CLI
- Defined in:
- lib/psgc/cli.rb
Constant Summary collapse
- COMMANDS =
%w[find hierarchy valid stats export help].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 17 |
# File 'lib/psgc/cli.rb', line 13 def initialize(argv) @argv = argv.dup @options = {} @success = false end |
Class Method Details
.run(argv = ARGV) ⇒ Object
9 10 11 |
# File 'lib/psgc/cli.rb', line 9 def self.run(argv = ARGV) new(argv).run end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/psgc/cli.rb', line 19 def run return help if @argv.empty? unless @command && COMMANDS.include?(@command) $stderr.puts "Error: unknown command '#{@command}'" return false end send(@command) @success end |