Class: Ace::Assign::CLI::Commands::Select

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/assign/cli/commands/select.rb

Overview

Select an assignment as current (sets .current symlink)

Examples:

Select by ID

ace-assign select abc123

Clear current selection

ace-assign select --clear

Instance Method Summary collapse

Instance Method Details

#call(id: nil, **options) ⇒ Object

Raises:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ace/assign/cli/commands/select.rb', line 24

def call(id: nil, **options)
  manager = Molecules::AssignmentManager.new

  if options[:clear]
    manager.clear_current
    puts "Cleared current assignment selection (will use most recent)" unless options[:quiet]
    return
  end

  raise Error, "Assignment ID required. Usage: ace-assign select <id> or ace-assign select --clear" unless id

  assignment = manager.set_current(id)

  unless options[:quiet]
    puts "Selected assignment: #{assignment.name} (#{assignment.id})"
  end
end