Class: OpenUSD::CLI
- Inherits:
-
Object
- Object
- OpenUSD::CLI
- Defined in:
- lib/openusd/cli.rb
Overview
Command-line interface used by the openusd executable.
Constant Summary collapse
- COMMANDS =
Supported subcommand names.
%w[cat tree zip].freeze
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr) ⇒ CLI
constructor
A new instance of CLI.
-
#run(arguments) ⇒ Integer
Run a command and return a process exit status.
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr) ⇒ CLI
Returns a new instance of CLI.
11 12 13 14 |
# File 'lib/openusd/cli.rb', line 11 def initialize(stdout: $stdout, stderr: $stderr) @stdout = stdout @stderr = stderr end |
Instance Method Details
#run(arguments) ⇒ Integer
Run a command and return a process exit status.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/openusd/cli.rb', line 19 def run(arguments) argv = arguments.dup command = argv.shift return print_help(0) if command.nil? || %w[-h --help help].include?(command) return print_version if %w[-v --version version].include?(command) return unknown_command(command) unless COMMANDS.include?(command) send("run_#{command}", argv) 0 rescue OptionParser::ParseError, ArgumentError, OpenUSD::Error, SystemCallError => e @stderr.puts("openusd: #{e.}") 1 end |