Sha256: 08c07e1657f0cf48d8dd281997338b35d6cb5622b210e2289560eaf900b7aa45

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

module MetaCon
  class Switch
    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
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metacon-0.1.6 lib/metacon/switch.rb
metacon-0.1.5 lib/metacon/switch.rb