diff --git a/README.md b/README.md index eb1532c..6a02f78 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ eton alias all-processes 2 eton alias all-processes processes # list all items -eton ls -Lall +eton ls -a # filter items containing words "thing" AND "some" eton ls thing some diff --git a/attr.go b/attr.go index 4088beb..24e59f5 100644 --- a/attr.go +++ b/attr.go @@ -228,7 +228,7 @@ func (attr Attr) Print(w *tabwriter.Writer, verbose bool, indent int, highlighte if attr.GetMark() == 0 { fmt.Fprintf(out, "[%s] %s\n", Color(attr.GetIdentifier(), "yellow+b"), attr.Title()) } else { - fmt.Fprintf(out, "[%s] %s\n", Color(attr.GetIdentifier(), "black+b:white"), Color(attr.Title(), "default")) + fmt.Fprintf(out, "%s %s\n", Color("["+attr.GetIdentifier()+"]", "black+b:white"), Color(attr.Title(), "default")) } if len(highlighteds) > 0 { fmt.Fprintln(out, attr.PrettyMatches(highlighteds, after)) @@ -582,7 +582,7 @@ func findAttributeByAliasOrID(db *sql.DB, alias_or_id string) (attr Attr) { func listWithFilters(db *sql.DB, opts Options) (attrs []Attr) { var stmt *sql.Stmt var rows *sql.Rows - var nolimit = opts.Limit == -1 || opts.IncludeRemoved + var nolimit = opts.Limit == -1 var sqlConditions string var sqlLimit string @@ -590,7 +590,7 @@ func listWithFilters(db *sql.DB, opts Options) (attrs []Attr) { queryValues := make([]interface{}, 0, 5) if opts.IncludeRemoved { - sqlConditions = "1" + sqlConditions = "deleted_at IS NOT NULL" } else { sqlConditions = "deleted_at IS NULL" } diff --git a/commands.go b/commands.go index f9b88e9..277493e 100644 --- a/commands.go +++ b/commands.go @@ -136,7 +136,6 @@ func cmdNew(db *sql.DB, opts Options) bool { go func() { for _ = range c { // CTRL-c - // Do nothing, this will continue executing the rest of the code } }() diff --git a/main.go b/main.go index e6e528f..7886c9b 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,7 @@ const dbfilename string = ".etondb" const usage string = `Usage: eton new [-|] [-v] - eton (ls|grep) [...] [-asl] [-o OFFSET] [-L LIMIT] [--after AFTER] + eton (ls|grep) [...] [-asl] [-o OFFSET] [-L LIMIT] [--after AFTER] [--removed] eton edit [...] [-v] eton alias eton unalias @@ -41,11 +41,13 @@ Options: -l, --list-files list items as filenames -s, --short short mode lists rows with aliases only -v, --verbose talk a lot - -a, --all include removed items as well + -a, --all list all items, alias for --limit -1 + --removed only removed items ` func main() { - args, _ := docopt.Parse(usage, nil, true, "version 0.0.0", false, true) + args, err := docopt.Parse(usage, nil, true, "version 0.0.0", false, true) + check(err) opts := OptionsFromArgs(args) @@ -56,7 +58,7 @@ func main() { dbfileExists := false - if _, err := os.Stat(dbfile); err == nil { + if _, err = os.Stat(dbfile); err == nil { dbfileExists = true } diff --git a/options.go b/options.go index 97fef8b..a403ece 100644 --- a/options.go +++ b/options.go @@ -53,7 +53,7 @@ func OptionsFromArgs(args map[string]interface{}) (opts Options) { opts.AfterLinesCount, err = strconv.Atoi(args["--after"].(string)) check(err) - if args["--limit"].(string) == "all" { + if args["--all"].(bool) || args["--limit"].(string) == "all" { opts.Limit = -1 } else { opts.Limit, err = strconv.Atoi(args["--limit"].(string)) @@ -109,7 +109,7 @@ func OptionsFromArgs(args map[string]interface{}) (opts Options) { opts.Filters = args[""].([]string) opts.FromStdin = args["-"].(bool) opts.Recursive = false // args["--recursive"].(bool) - opts.IncludeRemoved = args["--all"].(bool) + opts.IncludeRemoved = args["--removed"].(bool) opts.ShortMode = args["--short"].(bool) opts.Verbose = args["--verbose"].(bool)