From 2a979cb9a43cf25899813bbf0ce705232a572842 Mon Sep 17 00:00:00 2001 From: Chakib Benziane Date: Fri, 1 Dec 2017 18:24:30 +0100 Subject: [PATCH] -i to list only ids (used in scripts) --- commands.go | 4 ++++ main.go | 3 ++- options.go | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index b294873..10c7476 100644 --- a/commands.go +++ b/commands.go @@ -110,6 +110,10 @@ func cmdLs(db *sql.DB, w *tabwriter.Writer, opts options) bool { for _, attr := range attrs { if opts.ListFilepaths { fmt.Println(attr.filepath()) + } else if opts.ListIDs { + val, err := attr.ID.Value() + check(err) + fmt.Printf("%d\n", val) } else { attr.print(w, opts.Recursive, opts.Indent, opts.Filters, opts.AfterLinesCount) } diff --git a/main.go b/main.go index 8b632a9..fac7764 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ const dbfilename string = ".etondb" const usage string = `Usage: eton new [-|] [-v] - eton (ls|grep) [...] [-asl] [-o OFFSET] [-L LIMIT] [--after AFTER] [--removed] + eton (ls|grep) [...] [-asli] [-o OFFSET] [-L LIMIT] [--after AFTER] [--removed] eton edit [...] [-v] eton alias eton unalias @@ -40,6 +40,7 @@ Options: -L, --limit LIMIT maximum number of rows returned, pass -Lall to list everything [default: 10] -r, --recursive recursive mode -l, --list-files list items as filenames + -i, --list-ids list items as ids -s, --short short mode lists rows with aliases only -v, --verbose talk a lot -a, --all list all items, alias for --limit -1 diff --git a/options.go b/options.go index cac4ee9..36b0f07 100644 --- a/options.go +++ b/options.go @@ -29,6 +29,7 @@ type options struct { ShortMode bool Verbose bool ListFilepaths bool + ListIDs bool MountPoint string Note string AfterLinesCount int @@ -43,6 +44,7 @@ func optionsFromArgs(args map[string]interface{}) (opts options) { opts.RootID = -1 opts.Indent = 0 opts.ListFilepaths = args["--list-files"].(bool) + opts.ListIDs = args["--list-ids"].(bool) if args[""] != nil { opts.Note = args[""].(string)