added --removed option

master
Sina Siadat 9 years ago
parent d7a62b76e8
commit 53b387ce03

@ -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

@ -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"
}

@ -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
}
}()

@ -20,7 +20,7 @@ const dbfilename string = ".etondb"
const usage string = `Usage:
eton new [-|<note>] [-v]
eton (ls|grep) [<filters>...] [-asl] [-o OFFSET] [-L LIMIT] [--after AFTER]
eton (ls|grep) [<filters>...] [-asl] [-o OFFSET] [-L LIMIT] [--after AFTER] [--removed]
eton edit [<ids>...] [-v]
eton alias <id1> <id2>
eton unalias <alias>
@ -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
}

@ -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["<filters>"].([]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)

Loading…
Cancel
Save