Skip to content

Commit

Permalink
Add ellipsis to long descriptions within search
Browse files Browse the repository at this point in the history
relative to the term width
  • Loading branch information
tj committed Apr 21, 2011
1 parent d953a13 commit b79d5c6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions bin/asset
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

var asset = require('../')
, exec = require('child_process').exec
, tty = require('tty')
, fs = require('fs');

/**
Expand Down Expand Up @@ -205,10 +206,21 @@ function info(name){
*/

function search(query) {
var size = tty.getWindowSize()
, padding = 30
, height = size.shift()
, width = size.shift() - padding;

asset.search(repo, query, function(name, entry){
var desc = entry.description
? '\033[90m: ' + entry.description + '\033[0m'
var desc = entry.description;
if (desc.length > width) {
desc = desc.substr(0, width - 3) + '...';
}

desc = desc
? '\033[90m: ' + desc + '\033[0m'
: '';

log(name, entry.version + ' ' + desc);
});
}
Expand Down

0 comments on commit b79d5c6

Please sign in to comment.