-i to list only ids (used in scripts)

master
Chakib Benziane 6 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 {
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)
}

@ -21,7 +21,7 @@ const dbfilename string = ".etondb"
const usage string = `Usage:
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 alias <id1> <id2>
eton unalias <alias>
@ -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

@ -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["<note>"] != nil {
opts.Note = args["<note>"].(string)

Loading…
Cancel
Save