mirror of
https://codeberg.org/scip/anydb.git
synced 2025-12-17 04:20:59 +01:00
added -i option to list to search case insensitive
This commit is contained in:
1
TODO.md
1
TODO.md
@@ -2,4 +2,3 @@
|
|||||||
- mime-type => exec app + value
|
- mime-type => exec app + value
|
||||||
- add waitgroup to db.go funcs
|
- add waitgroup to db.go funcs
|
||||||
- RestList does not support any params?
|
- RestList does not support any params?
|
||||||
- case sensitive search: make it insensitive or add -i
|
|
||||||
|
|||||||
@@ -206,14 +206,16 @@ The B<list> subcommand displays a list of all database entries.
|
|||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
anydb list [<filter-regex>] [-t <tag>] [-m <mode>] [-n -N] [-T <tpl>] [flags]
|
anydb list [<filter-regex>] [-t <tag>] [-m <mode>] [-n -N] [-T <tpl>] [-i] [flags]
|
||||||
|
|
||||||
Aliases:
|
Aliases:
|
||||||
list, /, ls
|
list, /, ls
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
|
-i, --case-insensitive filter case insensitive
|
||||||
-h, --help help for list
|
-h, --help help for list
|
||||||
-m, --mode string output format (table|wide|json|template), wide is a verbose table. (default 'table')
|
-m, --mode string output format (table|wide|json|template),
|
||||||
|
wide is a verbose table. (default 'table')
|
||||||
-n, --no-headers omit headers in tables
|
-n, --no-headers omit headers in tables
|
||||||
-N, --no-human do not translate to human readable values
|
-N, --no-human do not translate to human readable values
|
||||||
-t, --tags stringArray tags, multiple allowed
|
-t, --tags stringArray tags, multiple allowed
|
||||||
@@ -250,6 +252,8 @@ L<https://github.com/google/re2/wiki/Syntax>. Please note, that this
|
|||||||
regexp dialect is not PCRE compatible, but supports most of its
|
regexp dialect is not PCRE compatible, but supports most of its
|
||||||
features.
|
features.
|
||||||
|
|
||||||
|
If you want to search case insensitive, add the option C<-i>.
|
||||||
|
|
||||||
You can - as with the B<get> command - use other output modes. The
|
You can - as with the B<get> command - use other output modes. The
|
||||||
default mode is "table". The "wide" mode is, as already mentioned, a
|
default mode is "table". The "wide" mode is, as already mentioned, a
|
||||||
more detailed table. Also supported is "json" mode and "template"
|
more detailed table. Also supported is "json" mode and "template"
|
||||||
|
|||||||
@@ -26,23 +26,24 @@ import (
|
|||||||
"github.com/tlinden/anydb/common"
|
"github.com/tlinden/anydb/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version string = "v0.0.6"
|
var Version string = "v0.0.7"
|
||||||
|
|
||||||
type BucketConfig struct {
|
type BucketConfig struct {
|
||||||
Encrypt bool
|
Encrypt bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
Dbfile string
|
Dbfile string
|
||||||
Dbbucket string
|
Dbbucket string
|
||||||
Template string
|
Template string
|
||||||
Mode string // wide, table, yaml, json
|
Mode string // wide, table, yaml, json
|
||||||
NoHeaders bool
|
NoHeaders bool
|
||||||
NoHumanize bool
|
NoHumanize bool
|
||||||
Encrypt bool // one entry
|
Encrypt bool // one entry
|
||||||
Listen string
|
CaseInsensitive bool
|
||||||
Buckets map[string]BucketConfig // config file only
|
Listen string
|
||||||
|
Buckets map[string]BucketConfig // config file only
|
||||||
|
|
||||||
Tags []string // internal
|
Tags []string // internal
|
||||||
DB *app.DB // internal
|
DB *app.DB // internal
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ func List(conf *cfg.Config) *cobra.Command {
|
|||||||
)
|
)
|
||||||
|
|
||||||
var cmd = &cobra.Command{
|
var cmd = &cobra.Command{
|
||||||
Use: "list [<filter-regex>] [-t <tag>] [-m <mode>] [-n -N] [-T <tpl>]",
|
Use: "list [<filter-regex>] [-t <tag>] [-m <mode>] [-n -N] [-T <tpl>] [-i]",
|
||||||
Short: "List database contents",
|
Short: "List database contents",
|
||||||
Long: `List database contents`,
|
Long: `List database contents`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
@@ -196,7 +196,11 @@ func List(conf *cfg.Config) *cobra.Command {
|
|||||||
cmd.SilenceUsage = true
|
cmd.SilenceUsage = true
|
||||||
|
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
attr.Args = args
|
if conf.CaseInsensitive {
|
||||||
|
attr.Args = []string{"(?i)" + args[0]}
|
||||||
|
} else {
|
||||||
|
attr.Args = args
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn comma list into slice, if needed
|
// turn comma list into slice, if needed
|
||||||
@@ -222,6 +226,7 @@ func List(conf *cfg.Config) *cobra.Command {
|
|||||||
cmd.PersistentFlags().BoolVarP(&wide, "wide-output", "l", false, "output mode: wide")
|
cmd.PersistentFlags().BoolVarP(&wide, "wide-output", "l", false, "output mode: wide")
|
||||||
cmd.PersistentFlags().BoolVarP(&conf.NoHeaders, "no-headers", "n", false, "omit headers in tables")
|
cmd.PersistentFlags().BoolVarP(&conf.NoHeaders, "no-headers", "n", false, "omit headers in tables")
|
||||||
cmd.PersistentFlags().BoolVarP(&conf.NoHumanize, "no-human", "N", false, "do not translate to human readable values")
|
cmd.PersistentFlags().BoolVarP(&conf.NoHumanize, "no-human", "N", false, "do not translate to human readable values")
|
||||||
|
cmd.PersistentFlags().BoolVarP(&conf.CaseInsensitive, "case-insensitive", "i", false, "filter case insensitive")
|
||||||
cmd.PersistentFlags().StringArrayVarP(&attr.Tags, "tags", "t", nil, "tags, multiple allowed")
|
cmd.PersistentFlags().StringArrayVarP(&attr.Tags, "tags", "t", nil, "tags, multiple allowed")
|
||||||
|
|
||||||
cmd.Aliases = append(cmd.Aliases, "/")
|
cmd.Aliases = append(cmd.Aliases, "/")
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
# simple entry
|
# simple entry
|
||||||
exec anydb -f test.db set foo bar
|
exec anydb -f test.db set foo bar
|
||||||
|
|
||||||
|
# single entry uc()
|
||||||
|
exec anydb -f test.db set MUCHAS gracias
|
||||||
|
|
||||||
# entry with tags
|
# entry with tags
|
||||||
exec anydb -f test.db set color grey -t flower,plant
|
exec anydb -f test.db set color grey -t flower,plant
|
||||||
|
|
||||||
@@ -37,6 +40,10 @@ exec anydb -f test.db list -t flower
|
|||||||
exec anydb -f test.db list b.r
|
exec anydb -f test.db list b.r
|
||||||
stdout bar
|
stdout bar
|
||||||
|
|
||||||
|
# list with -i filter
|
||||||
|
exec anydb -f test.db list -i mucha
|
||||||
|
stdout MUCHA
|
||||||
|
|
||||||
# get single entry
|
# get single entry
|
||||||
exec anydb -f test.db get color
|
exec anydb -f test.db get color
|
||||||
stdout grey
|
stdout grey
|
||||||
|
|||||||
Reference in New Issue
Block a user