From bd2cbfce8f59ccf0be91d97a0168f3468d1b1b86 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Wed, 27 Jan 2016 12:56:38 -0800 Subject: [PATCH] Limiting the alloc and eval ids based on short/verbose flags --- command/fs_cat.go | 9 +++++++-- command/fs_list.go | 9 +++++++-- command/fs_stat.go | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/command/fs_cat.go b/command/fs_cat.go index 9b9fcf355..19418db92 100644 --- a/command/fs_cat.go +++ b/command/fs_cat.go @@ -65,6 +65,11 @@ func (f *FSCatCommand) Run(args []string) int { return 1 } + // Truncate the id unless full length is requested + length := shortId + if verbose { + length = fullId + } // Query the allocation info alloc, _, err := client.Allocations().Info(allocID, nil) if err != nil { @@ -93,8 +98,8 @@ func (f *FSCatCommand) Run(args []string) int { out[0] = "ID|Eval ID|Job ID|Task Group|Desired Status|Client Status" for i, alloc := range allocs { out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s", - alloc.ID, - alloc.EvalID, + limit(alloc.ID, length), + limit(alloc.EvalID, length), alloc.JobID, alloc.TaskGroup, alloc.DesiredStatus, diff --git a/command/fs_list.go b/command/fs_list.go index 473fdc7e6..6ce11d9ad 100644 --- a/command/fs_list.go +++ b/command/fs_list.go @@ -64,6 +64,11 @@ func (f *FSListCommand) Run(args []string) int { return 1 } + // Truncate the id unless full length is requested + length := shortId + if verbose { + length = fullId + } // Query the allocation info alloc, _, err := client.Allocations().Info(allocID, nil) if err != nil { @@ -92,8 +97,8 @@ func (f *FSListCommand) Run(args []string) int { out[0] = "ID|Eval ID|Job ID|Task Group|Desired Status|Client Status" for i, alloc := range allocs { out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s", - alloc.ID, - alloc.EvalID, + limit(alloc.ID, length), + limit(alloc.EvalID, length), alloc.JobID, alloc.TaskGroup, alloc.DesiredStatus, diff --git a/command/fs_stat.go b/command/fs_stat.go index 60f78dacc..00de49ca3 100644 --- a/command/fs_stat.go +++ b/command/fs_stat.go @@ -63,6 +63,11 @@ func (f *FSStatCommand) Run(args []string) int { return 1 } + // Truncate the id unless full length is requested + length := shortId + if verbose { + length = fullId + } // Query the allocation info alloc, _, err := client.Allocations().Info(allocID, nil) if err != nil { @@ -91,8 +96,8 @@ func (f *FSStatCommand) Run(args []string) int { out[0] = "ID|Eval ID|Job ID|Task Group|Desired Status|Client Status" for i, alloc := range allocs { out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s", - alloc.ID, - alloc.EvalID, + limit(alloc.ID, length), + limit(alloc.EvalID, length), alloc.JobID, alloc.TaskGroup, alloc.DesiredStatus,