Class: Uprb::CLI
- Inherits:
-
Object
- Object
- Uprb::CLI
- Defined in:
- lib/uprb/cli.rb
Constant Summary collapse
- USAGE =
<<~USAGE.chomp Usage: uprb pack <src.rb> <dest> uprb gem install <gem> [--path DIR] uprb gem pack <gem> [--path DIR] USAGE
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.
20 21 22 |
# File 'lib/uprb/cli.rb', line 20 def initialize(argv) @argv = argv.dup end |
Class Method Details
.start(argv = ARGV) ⇒ Object
16 17 18 |
# File 'lib/uprb/cli.rb', line 16 def self.start(argv = ARGV) new(argv).run end |
Instance Method Details
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/uprb/cli.rb', line 24 def run command = @argv.shift case command when "pack" pack_command when "gem" gem_command when "--version", "-v" $stdout.puts(Uprb::VERSION) when "--help", "-h", nil $stdout.puts(USAGE) else $stderr.puts(USAGE) end rescue Uprb::Error => e $stderr.puts("uprb: #{e.}") exit 1 rescue StandardError => e $stderr.puts("uprb: #{e.class}: #{e.}") exit 1 end |