Class: DuoRuby::CLI
- Inherits:
-
Object
- Object
- DuoRuby::CLI
- Defined in:
- lib/duoruby/cli.rb
Overview
Command-line interface for the duoruby executable.
Commands:
-
help— prints usage information -
version— prints the gem version -
serve— starts the HTTP/WebSocket server (accepts--hostand--portoptions) -
launch— starts the server and opens a native webview window
All commands return an integer exit code. duoruby/server is required lazily by serve to avoid loading Falcon/Async for other commands.
Instance Method Summary collapse
-
#call ⇒ Integer
Dispatches to the appropriate command handler.
-
#initialize(args, input:, output:) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize(args, input:, output:) ⇒ CLI
Returns a new instance of CLI.
23 24 25 26 27 |
# File 'lib/duoruby/cli.rb', line 23 def initialize(args, input:, output:) @args = args @input = input @output = output end |
Instance Method Details
#call ⇒ Integer
Dispatches to the appropriate command handler.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/duoruby/cli.rb', line 32 def call case @args.first when nil, "help", "--help", "-h" help when "version", "--version", "-v" @output.puts VERSION 0 when "serve" serve when "launch" launch else @output.puts "unknown command: #{@args.first}" 1 end end |