Class: Rails::Worktrees::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/worktrees/cli.rb

Overview

Shell entrypoint for the wt executable.

Constant Summary collapse

LOADER_OPTIONAL_COMMANDS =
%w[doctor update -h --help -v --version].freeze
LOADER_IGNORED_FLAGS =
%w[--dry-run --force --skip-setup].freeze
SETUP_SUBCOMMAND =
'setup'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(argv: ARGV, io: { stdin: $stdin, stdout: $stdout, stderr: $stderr }, env: ENV, cwd: Dir.pwd) ⇒ CLI

Returns a new instance of CLI.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rails/worktrees/cli.rb', line 9

def initialize(
  argv: ARGV,
  io: { stdin: $stdin, stdout: $stdout, stderr: $stderr },
  env: ENV,
  cwd: Dir.pwd
)
  @argv = argv
  @io = io
  @env = env
  @cwd = cwd
end

Instance Method Details

#startObject



21
22
23
24
25
26
27
28
# File 'lib/rails/worktrees/cli.rb', line 21

def start
  configuration = ::Rails::Worktrees.configuration
  load_project_configuration(configuration) if should_load_project_configuration?
  command_for(configuration).run
rescue ::Rails::Worktrees::Error => e
  @io.fetch(:stderr).puts("Error: #{e.message}")
  1
end