Permalink
Browse files

Prettify list.

  • Loading branch information...
1 parent 8763fba commit 79d441490c0391e95fd4ae305a74036524eeeb18 @jbarnette committed Jul 27, 2010
Showing with 14 additions and 1 deletion.
  1. +14 −1 bin/basis
View
@@ -75,7 +75,20 @@ begin
@repo.add url, name
when "ls", "list" then
- @repo.templates(ARGV.shift).each { |name, template| puts name }
+ templates = @repo.templates ARGV.shift
+ width = templates.keys.map(&:length).max
+ max = 80 - width - 5
+
+ templates.keys.sort.each do |name|
+ template = templates[name]
+ desc = template.description
+
+ if desc.length > max
+ desc = desc[0, max - 3] + "..."
+ end
+
+ printf "%-#{width}s # #{desc}\n", name
+ end
when "mv", "rename" then
help! "Need names!" unless (old, new = ARGV) && old && new

0 comments on commit 79d4414

Please sign in to comment.