Class: SpaceArchitect::CLI::New
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- SpaceArchitect::CLI::New
- Includes:
- GlobalOptions, Helpers
- Defined in:
- lib/space_architect/cli/new.rb
Instance Method Summary collapse
Methods included from Helpers
#display_date, #handle_errors, #project_config, #render, #setup_terminal, #state, #store, #terminal
Methods included from GlobalOptions
Instance Method Details
#call(title:, repos: [], git: true, **opts) ⇒ Object
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 |
# File 'lib/space_architect/cli/new.rb', line 14 def call(title:, repos: [], git: true, **opts) setup_terminal(**opts.slice(:color, :colors)) result = store.create(title, git: git).bind do |space| terminal.success "Created #{space.id}" repo_specs = Array(repos).compact repo_specs.each { |spec| terminal.say "Queued #{spec}" } next Success(space) if repo_specs.empty? progress = RepoProgress.new(repo_specs.length) terminal.with_spinner(-> { progress. }) do store.add_repos_to(space, repo_specs, reporter: progress) end.fmap do |results| results.each do |r| terminal.success "Added #{r.fetch(:repo).fetch('full_name')}" terminal.say terminal.path(r.fetch(:path)) end space end end render(result) do |space| terminal.say terminal.path(space.path) CLI.record_outcome(Outcome.new(exit_code: 0)) end end |