Class: Rwm::Commands::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/rwm/commands/init.rb

Constant Summary collapse

GEMFILE_TEMPLATE =
<<~GEMFILE
  # frozen_string_literal: true

  source "https://rubygems.org"

  gem "rake"
  gem "ruby_workspace_manager"
GEMFILE
RAKEFILE_TEMPLATE =
<<~RAKEFILE
  # frozen_string_literal: true

  task :bootstrap do
    puts "Add your workspace-level bootstrap steps here."
    puts "This task runs during `rwm bootstrap` — use it for binstubs, shared tooling, etc."
  end
RAKEFILE

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Init

Returns a new instance of Init.



28
29
30
31
32
# File 'lib/rwm/commands/init.rb', line 28

def initialize(argv)
  @argv = argv
  @vscode = false
  parse_options
end

Instance Method Details

#runObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rwm/commands/init.rb', line 34

def run
  root = detect_git_root

  create_directories(root)
  create_gemfile(root)
  create_rakefile(root)
  update_gitignore(root)

  if @vscode
    generate_vscode_workspace(root)
  end

  puts "Workspace initialized. Running bootstrap..."
  puts

  # Call bootstrap as the last step — return its exit code
  require "rwm/commands/bootstrap"
  Commands::Bootstrap.new([]).run
  0
end