6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/metacon/switch.rb', line 6
def self.handle(cmd, clo, opts)
if opts.nil? or opts.size == 0
all = $proj.list(cmd)
current = $proj.current_state[cmd]
all.sort.each do |avail|
if avail == current
$cli.cputs "* |{green #{avail}}"
else
puts " #{avail}"
end
end
else
res = $proj.switch({cmd=>opts[0]}, clo)
case res
when :nochange
$cli.cwarn 'Nothing changed' if clo[:verbose]
when :switched
$cli.result "Switched #{cmd} to '#{opts[0]}'" if clo[:verbose]
when :incomplete
$cli.cwarn "Not all dependencies loaded."
$cli.result "Switched #{cmd} to '#{opts[0]}' more or less." if clo[:verbose]
when :impossible
$cli.cfail 'Cannot switch. Probably because submodules need committing.'
end
MetaCon::Stat.curr(opts,$proj,clo)
end
end
|