Class: SpaceArchitect::CLI::Architect::Section

Inherits:
Dry::CLI::Command
  • Object
show all
Includes:
GlobalOptions, Helpers
Defined in:
lib/space_architect/cli/architect.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

included

Instance Method Details

#call(iteration:, section:, space: nil, from: nil, body: nil, stdin: false, append: false, lane: nil, **opts) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/space_architect/cli/architect.rb', line 218

def call(iteration:, section:, space: nil, from: nil, body: nil, stdin: false, append: false, lane: nil, **opts)
  setup_terminal(**opts.slice(:color, :colors))
  handle_errors do
    content = read_section_body(from: from, body: body, stdin: stdin)
    render(store.find(space)) do |sp|
      mission = ArchitectMission.new(space: sp)
      res = mission.write_section!(iteration, section, body: content, append: append, lane: lane)
      if res[:committed]
        terminal.say "Committed #{res[:heading]}#{res[:sha][0, 8]}"
        terminal.say res[:diffstat] unless res[:diffstat].empty?
      else
        terminal.say "#{res[:heading]} written — no change to commit"
      end
      CLI.record_outcome(Outcome.new(exit_code: 0))
    end
  end
end