Skip to content

Commit

Permalink
Prettify list.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarnette committed Jul 27, 2010
1 parent 8763fba commit 79d4414
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion bin/basis
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79d4414

Please sign in to comment.