Browse files

add list strings and list default string

  • Loading branch information...
1 parent d5095e3 commit 63827e4c1a88b73c43c972390a4acd9bf7b9625d @vertiginous committed Jan 20, 2011
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/pik/commands/list_command.rb
View
18 lib/pik/commands/list_command.rb
@@ -12,7 +12,9 @@ def execute
when 'known'
remote_list
when 'default'
- default_list
+ default_string? ? default_list(:strings) : default_list
+ when 'strings'
+ list(:string)
else
if remote
remote_list
@@ -30,19 +32,26 @@ def remote_list
end
end
- def default_list
+ def default_list(type=:simple)
puts "Default Ruby\n\n"
if default = config.match(config.global[:default])
- puts layout(*default)
+ name, config = *default
+ name = VersionPattern.full(name) if type == :simple
+ puts layout(name, config)
else
puts "no default assigned."
puts "run 'pik use [ruby] --default' to assign one"
puts
end
end
- def list
+ def default_string?
+ @args[1] == 'string'
+ end
+
+ def list(type=:simple)
config.sort.each do |name, conf|
+ name = VersionPattern.full(name) if type == :simple
puts layout(name, conf)
puts conf.map{|k,v| " %s: %s" % [k, v]} + ["\n"] if verbose
end
@@ -51,7 +60,6 @@ def list
private
def layout(name, conf)
- name = VersionPattern.full(name)
name = current?(conf) ? "=> #{name}" : " #{name}"
if name.length > columns
remainder = -(name.length - columns + 5)

0 comments on commit 63827e4

Please sign in to comment.