-i to list only ids (used in scripts)

master
Chakib Benziane 7 years ago
parent bf0ff020f7
commit 2a979cb9a4

@ -110,6 +110,10 @@ func cmdLs(db *sql.DB, w *tabwriter.Writer, opts options) bool {
for _, attr := range attrs { for _, attr := range attrs {
if opts.ListFilepaths { if opts.ListFilepaths {
fmt.Println(attr.filepath()) fmt.Println(attr.filepath())
} else if opts.ListIDs {
val, err := attr.ID.Value()
check(err)
fmt.Printf("%d\n", val)
} else { } else {
attr.print(w, opts.Recursive, opts.Indent, opts.Filters, opts.AfterLinesCount) attr.print(w, opts.Recursive, opts.Indent, opts.Filters, opts.AfterLinesCount)
} }

@ -21,7 +21,7 @@ const dbfilename string = ".etondb"
const usage string = `Usage: const usage string = `Usage:
eton new [-|<note>] [-v] eton new [-|<note>] [-v]
eton (ls|grep) [<filters>...] [-asl] [-o OFFSET] [-L LIMIT] [--after AFTER] [--removed] eton (ls|grep) [<filters>...] [-asli] [-o OFFSET] [-L LIMIT] [--after AFTER] [--removed]
eton edit [<ids>...] [-v] eton edit [<ids>...] [-v]
eton alias <id1> <id2> eton alias <id1> <id2>
eton unalias <alias> eton unalias <alias>
@ -40,6 +40,7 @@ Options:
-L, --limit LIMIT maximum number of rows returned, pass -Lall to list everything [default: 10] -L, --limit LIMIT maximum number of rows returned, pass -Lall to list everything [default: 10]
-r, --recursive recursive mode -r, --recursive recursive mode
-l, --list-files list items as filenames -l, --list-files list items as filenames
-i, --list-ids list items as ids
-s, --short short mode lists rows with aliases only -s, --short short mode lists rows with aliases only
-v, --verbose talk a lot -v, --verbose talk a lot
-a, --all list all items, alias for --limit -1 -a, --all list all items, alias for --limit -1

@ -29,6 +29,7 @@ type options struct {
ShortMode bool ShortMode bool
Verbose bool Verbose bool
ListFilepaths bool ListFilepaths bool
ListIDs bool
MountPoint string MountPoint string
Note string Note string
AfterLinesCount int AfterLinesCount int
@ -43,6 +44,7 @@ func optionsFromArgs(args map[string]interface{}) (opts options) {
opts.RootID = -1 opts.RootID = -1
opts.Indent = 0 opts.Indent = 0
opts.ListFilepaths = args["--list-files"].(bool) opts.ListFilepaths = args["--list-files"].(bool)
opts.ListIDs = args["--list-ids"].(bool)
if args["<note>"] != nil { if args["<note>"] != nil {
opts.Note = args["<note>"].(string) opts.Note = args["<note>"].(string)

Loading…
Cancel
Save