triton packages: make --human the default, use -p to override. Nicer, some what kludged sorting by group and memory
This commit is contained in:
parent
016e2d94f0
commit
022471afa7
@ -46,7 +46,19 @@ function do_packages (subcmd, opts, args, callback) {
|
|||||||
for (var i = 0; i < pkgs.length; i++) {
|
for (var i = 0; i < pkgs.length; i++) {
|
||||||
var pkg = pkgs[i];
|
var pkg = pkgs[i];
|
||||||
pkg.shortid = pkg.id.split('-', 1)[0];
|
pkg.shortid = pkg.id.split('-', 1)[0];
|
||||||
if (opts.human) {
|
|
||||||
|
/*
|
||||||
|
* We take a slightly "smarter" view of "group" for default
|
||||||
|
* sorting, to accomodate usage in the JPC. More recent
|
||||||
|
* common usage is for packages to have "foo-*" naming.
|
||||||
|
* JPC includes package sets of yore *and* recent that don't
|
||||||
|
* use the "group" field. We secondarily separate those
|
||||||
|
* on a possible "foo-" prefix.
|
||||||
|
*/
|
||||||
|
pkg._groupPlus = (pkg.group || (pkg.name.indexOf('-') === -1
|
||||||
|
? "" : pkg.name.split('-', 1)[0]));
|
||||||
|
|
||||||
|
if (!opts.p) {
|
||||||
pkg.memoryHuman = common.humanSizeFromBytes({
|
pkg.memoryHuman = common.humanSizeFromBytes({
|
||||||
precision: 1,
|
precision: 1,
|
||||||
narrow: true
|
narrow: true
|
||||||
@ -61,7 +73,7 @@ function do_packages (subcmd, opts, args, callback) {
|
|||||||
}, pkg.disk * 1024 * 1024);
|
}, pkg.disk * 1024 * 1024);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opts.human) {
|
if (!opts.p) {
|
||||||
columns = columns.map(function (c) {
|
columns = columns.map(function (c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'memory':
|
case 'memory':
|
||||||
@ -113,14 +125,14 @@ do_packages.options = [
|
|||||||
{
|
{
|
||||||
names: ['s'],
|
names: ['s'],
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'name',
|
default: '_groupPlus,memory',
|
||||||
help: 'Sort on the given fields. Default is "name".',
|
help: 'Sort on the given fields. Default is "group,memory".',
|
||||||
helpArg: 'field1,...'
|
helpArg: 'field1,...'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
names: ['human'],
|
names: ['p'],
|
||||||
type: 'bool',
|
type: 'bool',
|
||||||
help: '"Human-readable" output. Show MiB, GiB, etc units for sizes.'
|
help: 'Display numbers in parsable (exact) values.'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
names: ['json', 'j'],
|
names: ['json', 'j'],
|
||||||
|
Reference in New Issue
Block a user