Module: Rooibos::CLI

Defined in:
lib/rooibos/cli.rb,
lib/rooibos/cli/commands/new.rb,
lib/rooibos/cli/commands/run.rb

Overview

Entry point for the Rooibos command-line interface.

Rooibos provides a CLI for common development tasks. Rather than remembering incantations for each tool, use a single command.

This module dispatches to subcommands. It routes new to project scaffolding and run to application execution.

Use it via the rooibos executable.

Example

# From terminal:
rooibos new my_app
cd my_app
rooibos run

# Programmatic access:
Rooibos::CLI.call(["new", "my_app"])
Rooibos::CLI.call(["run"])

Defined Under Namespace

Modules: Commands

Constant Summary collapse

COMMANDS =

Maps command names to handler modules.

{ # :nodoc:
  "new" => Commands::New,
  "run" => Commands::Run,
}.freeze

Class Method Summary collapse

Class Method Details

.call(argv) ⇒ Object

Entry point for the CLI.

argv

Command-line arguments array.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rooibos/cli.rb', line 43

def self.call(argv)
  command_name = argv.shift

  case command_name
  when "--version", "-v"
    puts "Rooibos #{Rooibos::VERSION}"
  when "--help", "-h", nil
    puts usage
  else
    command = COMMANDS[command_name]
    if command
      command.call(argv)
    else
      warn "Unknown command: #{command_name}"
      warn usage
      exit(1)
    end
  end
end

.usageObject

Returns the main usage message.



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/rooibos/cli.rb', line 64

def self.usage
  <<~USAGE
    Usage: rooibos <command> [options]

    Commands:
      new <appname>  Create a new Rooibos application
      run            Run the application in the current directory

    Options:
      --version, -v  Show version
      --help, -h     Show this help
  USAGE
end