Module: Rooibos::CLI::Commands::New

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

Overview

Scaffolds a new Rooibos TUI application.

Starting a TUI project from scratch is tedious. Gem structure, test setup, executable wiring, and dependency management all take time before you write your first line of application code.

This command delegates to bundle gem for the boilerplate, then customizes the result for Rooibos. It creates a working Model-View-Update skeleton with a passing test.

Use it to bootstrap new projects.

Example

rooibos new my_app
rooibos new my_app --no-git
rooibos new my_app --test=rspec  # warns about TestHelper

Constant Summary collapse

BUNDLE_GEM_DEFAULTS =

Default flags for bundle gem. Note: We use –no-bundle so we can add rooibos to Gemfile first.

%w[
  --exe
  --no-coc
  --changelog
  --no-ext
  --git
  --no-mit
  --test=minitest
  --no-ci
  --linter=rubocop
  --no-bundle
].freeze

Class Method Summary collapse

Class Method Details

.call(argv) ⇒ Object

Runs the new command.

argv

Command-line arguments (expects app name as first element).



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rooibos/cli/commands/new.rb', line 52

def self.call(argv)
  options = parse_options(argv)

  if options[:help]
    puts usage
    exit(0)
  end

  if argv.empty?
    warn "Error: Missing application name"
    warn usage
    exit(1)
  end

  app_name = argv.shift
  passthrough_args = argv # Remaining args passed to bundle gem

  create_app(app_name, passthrough_args, options)
end

.usageObject

Returns command-specific usage.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/rooibos/cli/commands/new.rb', line 73

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

    Creates a new Rooibos TUI application using `bundle gem`.

    Arguments:
      <appname>   Name of the application to create

    Options:
      --help, -h  Show this help

    Bundle Gem Defaults (can be overridden):
      --exe           Create executable (enabled by default)
      --no-coc        No Code of Conduct (default)
      --changelog     Generate CHANGELOG.md (default)
      --no-ext        No native extension (default)
      --git           Initialize git repo (default)
      --no-mit        No MIT license (default)
      --test=minitest Use Minitest (default, recommended)
      --no-ci         No CI config (default)
      --linter=rubocop Use RuboCop (default)
      --bundle        Run bundle install (default)

    Any bundle gem option can be passed through, for example:
      rooibos new my_app --no-git
      rooibos new my_app --test=rspec  # warns about TestHelper

    Note: Rooibos::TestHelper is only verified to work with Minitest.
  USAGE
end