Class: Rwm::Commands::Init

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

Constant Summary collapse

GEMFILE_TEMPLATE =
"# frozen_string_literal: true\n\nsource \"https://rubygems.org\"\n\ngem \"rake\"\ngem \"ruby_workspace_manager\"\n"
RAKEFILE_TEMPLATE =
"# frozen_string_literal: true\n\ntask :bootstrap do\n  puts \"Add your workspace-level bootstrap steps here.\"\n  puts \"This task runs during `rwm bootstrap` \u2014 use it for binstubs, shared tooling, etc.\"\nend\n"

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