Class: Rwm::Commands::New
- Inherits:
-
Object
- Object
- Rwm::Commands::New
- Defined in:
- lib/rwm/commands/new.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ New
constructor
A new instance of New.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ New
Returns a new instance of New.
8 9 10 |
# File 'lib/rwm/commands/new.rb', line 8 def initialize(argv) @argv = argv end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rwm/commands/new.rb', line 12 def run type = @argv.shift name = @argv.shift unless %w[app lib].include?(type) $stderr.puts "Usage: rwm new <app|lib> <name>" return 1 end unless name && name.match?(/\A[a-z][a-z0-9_]*\z/) $stderr.puts "Package name must start with a lowercase letter and contain only lowercase letters, digits, and underscores." return 1 end workspace = Workspace.find dir = type == "lib" ? "libs" : "apps" pkg_path = File.join(workspace.root, dir, name) raise PackageExistsError, name if File.directory?(pkg_path) scaffold(pkg_path, name, type) update_vscode_workspace(workspace) puts "Created #{type} '#{name}' at #{dir}/#{name}/" puts puts "Next steps:" puts " cd #{dir}/#{name}" puts " bundle install" puts " rwm graph # rebuild the dependency graph" 0 end |