Permalink
Browse files

Add ellipsis to long descriptions within search

relative to the term width
  • Loading branch information...
1 parent d953a13 commit b79d5c64e3ee7eaed8c7ecef7c86efbd4aaa8bfc @tj tj committed Apr 21, 2011
Showing with 14 additions and 2 deletions.
  1. +14 −2 bin/asset
View
@@ -6,6 +6,7 @@
var asset = require('../')
, exec = require('child_process').exec
+ , tty = require('tty')
, fs = require('fs');
/**
@@ -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);
});
}

0 comments on commit b79d5c6

Please sign in to comment.