-
-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement feature "Support custom colours" #197
Conversation
# imported collections module for named tuple # add "colormap" from googler project # add named tuple for id and title, url, desc, tag # adjusted print_single_rec so colors can be changed for each item # add valid color string checker from googler # adjusted man options # add autocompletions
# sorted import in alphabetical order # adjusted var name's # add colors table to man file # add color os ENV option # add --color documentation in README under "Usage"
@@ -26,6 +26,7 @@ _buku () { | |||
-k --unlock | |||
-l --lock | |||
-m --merge | |||
--colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The options are in alphabetical order. Same for all the completion scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as well as all completion scripts.
buku.1
Outdated
@@ -218,6 +218,9 @@ Show selective monochrome output with specific fields. Works with --print. Searc | |||
.BI \-j " " \--json | |||
Output data formatted as json, works with --print output and search results. | |||
.TP | |||
.BI "--colors=" COLORS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the following syntax like it's for other options in this man page:
.BI \--colors " COLORS"
buku.1
Outdated
.TE | ||
.TP | ||
.TP | ||
The default colors string is \fIGKlg\fR, which stands for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awful. See my comment on line 3306 for more details.
buku.py
Outdated
DESC_str = '%s + %s\n' | ||
TAG_str = '%s # %s\n' | ||
colors = Colors(*[COLORMAP[c] for c in args.colorstr], reset=COLORMAP['x']) | ||
ID_DB_str = colors.ID_DB_str + ID_DB_str + COLORMAP['x'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The color for ID+title reflects in buku -p
but not for the search results. Please fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have not used ID_str. That's the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have something similar to googler?
ID - bold cyan (G
)
Title - bold bright green (K
)
DB Index (within []) - \x1b[2m
(keep it hardcoded to dim)
URL - bright yellow (l
)
comments/notes/desc - normal (x
)
tags - blue (e
)
Testing: Add a bookmark with url, title, tags and comment. Then
- print it
- search for it
to ensure your changes are good.
buku.py
Outdated
@@ -3216,6 +3249,8 @@ def main(): | |||
addarg('-p', '--print', nargs='*', help=HIDE) | |||
addarg('-f', '--format', type=int, default=0, choices={1, 2, 3, 4}, help=HIDE) | |||
addarg('-j', '--json', action='store_true', help=HIDE) | |||
addarg('--colors', dest='colorstr', type=argparser.is_colorstr, | |||
default=colorstr_env if colorstr_env else 'GKlg', metavar='COLORS', help=HIDE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change. See my comment on line 3306 for more details.
buku.py
Outdated
DESC_str = '%s + %s\n' | ||
TAG_str = '%s # %s\n' | ||
colors = Colors(*[COLORMAP[c] for c in args.colorstr], reset=COLORMAP['x']) | ||
ID_DB_str = colors.ID_DB_str + ID_DB_str + COLORMAP['x'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have not used ID_str. That's the problem.
buku.py
Outdated
DESC_str = '%s + %s\n' | ||
TAG_str = '%s # %s\n' | ||
colors = Colors(*[COLORMAP[c] for c in args.colorstr], reset=COLORMAP['x']) | ||
ID_DB_str = colors.ID_DB_str + ID_DB_str + COLORMAP['x'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have something similar to googler?
ID - bold cyan (G
)
Title - bold bright green (K
)
DB Index (within []) - \x1b[2m
(keep it hardcoded to dim)
URL - bright yellow (l
)
comments/notes/desc - normal (x
)
tags - blue (e
)
Testing: Add a bookmark with url, title, tags and comment. Then
- print it
- search for it
to ensure your changes are good.
Please go through my comments and make the changes accordingly. This is a VERY important feature. Anything odd in default colors can put off all the users and kill the utility. |
@ALL I would love to keep the defaults similar to |
README.md
Outdated
@@ -206,6 +206,7 @@ POWER TOYS: | |||
N=1: URL, N=2: URL and tag, N=3: title, | |||
N=4: URL, title and tag | |||
-j, --json Json formatted output for -p and search | |||
--colors set output colors (see man page for details) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make mention of this feature under the Features section as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to go in 2 places under features: README and man page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additions to the examples in both the README and man page may be helpful as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove (see man page for details)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from my comment with regards to Features section addition. I love this.
buku.1
Outdated
@@ -336,6 +339,75 @@ http[s]://[username:password@]proxyhost:proxyport/ | |||
can be integrated in a GUI environment with simple tweaks. Refer to: | |||
.br | |||
.I https://github.com/jarun/Buku#gui-integration | |||
.SH COLORS | |||
\buku\fR allows you to customize the color scheme via a four-letter string, reminiscent of BSD \fBLSCOLORS\fR. The four letters represent the colors of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\buku\fR
should be \fBBuku\fR
, I think. It currently displays as k
.
buku.py
Outdated
DESC_str = colors.DESC_str + DESC_str + COLORMAP['x'] | ||
TAG_str = colors.TAG_str + TAG_str + COLORMAP['x'] | ||
else: | ||
print('no') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this should be a more explicit message? I'm not sure of the case that would trigger this, though. It seems like it might not be needed, since args.colorstr
has a default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least minimal debug msg
buku.py
Outdated
for c in arg: | ||
assert c in COLORMAP | ||
except AssertionError: | ||
raise argparse.ArgumentTypeError('%s is not a valid color string' % arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an invalid color string is set as the env variable (e.g., ixejJ
), the raised error message is buku.py: error: argument --colors: ixejJ is not a valid color string
. Maybe not a problem, but this might be confusing since --colors
is not used in that case by the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change it to ixejJ is not a valid color string
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this feature a lot. I made some suggestions, but the only imperative one on my end would be the typo in the man page.
simple test would be helpful for is_colorstr would be helpful for maintenance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need test on is_colorstr
--color reordered in alphabetical order
--color reordered in alphabetical order
--color reordered in alphabetical order
auto-completion/fish/buku.fish
Outdated
@@ -6,6 +6,7 @@ | |||
# | |||
complete -c buku -s a -l add -r --description 'add bookmark' | |||
complete -c buku -l ai --description 'auto-import bookmarks' | |||
complete -c buku -l colors --description 'set output colors (see man page for details)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This takes an arg. Add -r
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove (see man page for details)
.
auto-completion/zsh/_buku
Outdated
@@ -11,6 +11,7 @@ local -a args | |||
args=( | |||
'(-a --add)'{-a,--add}'[add bookmark]:URL tags' | |||
'(--ai)--ai[auto-import bookmarks]' | |||
'(--colors)--colors[set output colors (see man page for details)]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to:
'(--colors)--colors[set output colors]:color string'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove (see man page for details)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
@@ -13,6 +13,7 @@ _buku () { | |||
opts=( | |||
-a --add | |||
--ai | |||
--colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also go into the opts_with_arg
group below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add to opts_with_arg
README.md
Outdated
@@ -206,6 +206,7 @@ POWER TOYS: | |||
N=1: URL, N=2: URL and tag, N=3: title, | |||
N=4: URL, title and tag | |||
-j, --json Json formatted output for -p and search | |||
--colors set output colors (see man page for details) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove (see man page for details)
.
auto-completion/fish/buku.fish
Outdated
@@ -6,6 +6,7 @@ | |||
# | |||
complete -c buku -s a -l add -r --description 'add bookmark' | |||
complete -c buku -l ai --description 'auto-import bookmarks' | |||
complete -c buku -l colors --description 'set output colors (see man page for details)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove (see man page for details)
.
auto-completion/zsh/_buku
Outdated
@@ -11,6 +11,7 @@ local -a args | |||
args=( | |||
'(-a --add)'{-a,--add}'[add bookmark]:URL tags' | |||
'(--ai)--ai[auto-import bookmarks]' | |||
'(--colors)--colors[set output colors (see man page for details)]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove (see man page for details)
.
buku.py
Outdated
@@ -3193,6 +3225,7 @@ def main(): | |||
N=1: URL, N=2: URL and tag, N=3: title, | |||
N=4: URL, title and tag | |||
-j, --json Json formatted output for -p and search | |||
--colors set output colors (see man page for details) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove (see man page for details)
.
# separated id from ID_str and ID_DB_STR so it can have separate color # add 5 string color for (id, title, url, desc, tag) # adjusted print_single_rec for 5 colors result # fixed syntax .BI \--colors " COLORS" in man page # replaced four with five letter string for color # fixed default colors to "GKlxe" and "\x1b[2m" for DB index # add example to README and man page # removed check for colorstr_env set by user for the moment
README.md
Outdated
@@ -192,6 +193,7 @@ ENCRYPTION OPTIONS: | |||
|
|||
POWER TOYS: | |||
--ai auto-import from Firefox and Chrome | |||
--colors set output colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For help, this was in the right position (just above --nc
). My comment was only for the auto-complete scripts.
Also, please change it to:
--colors COLORS set output colors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misunderstanding no problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Please take your time. This is a big PR, so nothing to hurry about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
buku.py
Outdated
@@ -3211,6 +3222,7 @@ def main(): | |||
power_grp = argparser.add_argument_group( | |||
title='POWER TOYS', | |||
description=''' --ai auto-import from Firefox and Chrome | |||
--colors set output colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--colors COLORS set output colors
and please move it back to just before --nc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
buku.1
Outdated
@@ -340,19 +341,21 @@ can be integrated in a GUI environment with simple tweaks. Refer to: | |||
.br | |||
.I https://github.com/jarun/Buku#gui-integration | |||
.SH COLORS | |||
\buku\fR allows you to customize the color scheme via a four-letter string, reminiscent of BSD \fBLSCOLORS\fR. The four letters represent the colors of | |||
\fBBuku\fR allows you to customize the color scheme via a five-letter string, reminiscent of BSD \fBLSCOLORS\fR. The five letters represent the colors of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the name to buku
i.e., starting with lowercase char.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
auto-completion/fish/buku.fish
Outdated
@@ -6,7 +6,7 @@ | |||
# | |||
complete -c buku -s a -l add -r --description 'add bookmark' | |||
complete -c buku -l ai --description 'auto-import bookmarks' | |||
complete -c buku -l colors --description 'set output colors (see man page for details)' | |||
complete -c buku -l colors --description 'set output colors' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to:
complete -c buku -l colors -r --description 'set output colors'
The -r
stands for required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
README.md
Outdated
@@ -66,6 +66,7 @@ PRs are welcome. Please visit [#174](https://github.com/jarun/Buku/issues/174) f | |||
- Portable, merge-able database to sync between systems | |||
- Multithreaded full DB refresh | |||
- Shell completion scripts, man page with handy examples | |||
- Colored output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move it to the top point:
Lightweight, clean interface, custom colors
And add this in the man page too (we show the features in man page as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
Also, flake8 check in Travis is failing due to some very long line. Please fix. |
buku.1
Outdated
@@ -182,6 +183,9 @@ Decrypt (unlock) the DB file with | |||
.BI \--ai | |||
Auto-import bookmarks from Firefox and Google Chrome. | |||
.TP | |||
.BI \--colors " COLORS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this to above --nc
there is only 1 issue I found with the colors, when u search with -t option and don't put any args it displays the amount of bookmarks without color |
buku.py
Outdated
@@ -48,12 +49,27 @@ | |||
colorize = True # Allow color output by default | |||
|
|||
# Default colour to print records | |||
ID_str = '\x1b[96;1m%d. \x1b[1;92m%s\x1b[0;2m [%s]\x1b[0m\n' | |||
ID_DB_str = '\x1b[96;1m%d. \x1b[1;92m%s\x1b[0m' | |||
ID_srch = '\x1b[36m%d.\x1b[0m' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The space after .
is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
buku.py
Outdated
ID_str = '\x1b[96;1m%d. \x1b[1;92m%s\x1b[0;2m [%s]\x1b[0m\n' | ||
ID_DB_str = '\x1b[96;1m%d. \x1b[1;92m%s\x1b[0m' | ||
ID_srch = '\x1b[36m%d.\x1b[0m' | ||
ID_str = ID_srch + '\x1b[1;92m%s\x1b[2m [%s]\x1b[0m\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DB ID is not showing in dim. In
2.GitHub - mewrev/dissection: The dissection of a simple "hello world" ELF binary. [305]
The [305]
at the end is the DB id. It is shown in search results. You have to use \x1b[0;2m
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
README.md
Outdated
@@ -66,7 +66,7 @@ PRs are welcome. Please visit [#174](https://github.com/jarun/Buku/issues/174) f | |||
- Portable, merge-able database to sync between systems | |||
- Multithreaded full DB refresh | |||
- Shell completion scripts, man page with handy examples | |||
- Colored output | |||
- Lightweight, clean interface, custom colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lightweight, clean interface
is already at the top of the feature list. Please append custom colors to it instead of a new entry at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah :) did not sleep yes i guess ok np
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected in both files
@@ -208,6 +207,7 @@ POWER TOYS: | |||
N=1: URL, N=2: URL and tag, N=3: title, | |||
N=4: URL, title and tag | |||
-j, --json Json formatted output for -p and search | |||
--colors --colors COLORS set output colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check googler's help on --colors
and copy it verbatim.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well googler's is:
--colors COLORS set output colors (see man page for details)
do you what to use this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. In that case just use whatever is there in googler.
buku.1
Outdated
@@ -23,7 +23,7 @@ is a command-line utility to store, tag, search and organize bookmarks. | |||
* Portable, merge-able database to sync between systems | |||
* Multithreaded full DB refresh | |||
* Shell completion scripts, man page with handy examples | |||
* Colored output | |||
* Lightweight, clean interface, custom colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be the topmost line.
buku.py
Outdated
@@ -3237,6 +3236,7 @@ def main(): | |||
N=1: URL, N=2: URL and tag, N=3: title, | |||
N=4: URL, title and tag | |||
-j, --json Json formatted output for -p and search | |||
--colors --colors COLORS set output colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
I'll take care of the rest of the changes. Thanks! |
used idea from googler project to add custom colors support
imported collections and used named tuple to store users colors from
"COLORMAP" which is identical with googler's project
separated vars in print_single_rec so color can be changed
separately for each item: id and title, url, desc, tag
add function to check for valid color strings and return error
msg if string is invalid
add check for os env defaults for colors that should be stored in $env:BUKU_COLORS
in args.colorstr ID_DB_str, URL_str, DESC_str, TAG_str
removes default colors and set users colors
updated man pages for colors option
updated auto-completions
updated README file under section "Usage"