Class: Reight::CLI
- Inherits:
-
Object
- Object
- Reight::CLI
- Defined in:
- lib/reight/cli.rb
Constant Summary collapse
- SUBCOMMANDS =
%w[run edit new package]
Instance Method Summary collapse
Instance Method Details
#help ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/reight/cli.rb', line 9 def help() <<~END Usage: r8 [options] <command> [args] Commands: run [DIR] run the game (default) edit [DIR] edit the game new NAME create a new project package [DIR] package as an application Options: -h, --help show this message -v, --version show version END end |
#run(argv) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/reight/cli.rb', line 25 def run(argv) argv, params = parse argv do |o| o.on('-h', '--help') {puts help; exit} o.on('-v', '--version') {puts Reight::Extension.version; exit} end case command = SUBCOMMANDS.include?(argv.first) ? argv.shift : 'run' when 'run' then start command, argv, edit: false when 'edit' then start command, argv, edit: true when 'new' then package command, argv when 'package' then package command, argv end rescue OptionParser::ParseError => e $stderr.puts "Error: #{e.}" exit 1 end |