Support lists and ranges in print function.
This commit is contained in:
parent
507e2d8bf9
commit
731eae5786
@ -14,7 +14,7 @@
|
||||
|
||||
`buku` is a powerful bookmark management utility written in Python3 and SQLite3. When I started writing it, I couldn't find a flexible cmdline solution with a private, portable, merge-able database along with browser integration. Hence, `buku` (after my son's nickname).
|
||||
|
||||
With tagging and multiple options to search through your bookmarks, including a deep scan mode (particularly for URLs), `buku` makes finding a bookmark very easy. You can open multiple bookmarks in the browser at once. It also has an Easter egg to open random bookmarks so you can revisit forgotten ones.
|
||||
With tagging and multiple options to search bookmarks, including a deep scan mode (particularly for URLs), `buku` makes finding a bookmark very easy. You can also open multiple bookmarks in the browser at once or revisit a random forgotten bookmark.
|
||||
|
||||
Though a terminal utility, it's possible to add bookmarks to `buku` without touching the terminal! Refer to the section on [GUI integration](#gui-integration). If you prefer the terminal, thanks to the shell completion scripts, you don't need to memorize any of the options.
|
||||
|
||||
@ -179,7 +179,8 @@ Shell completion scripts for Bash, Fish and Zsh can be found in respective subdi
|
||||
-i, --import file import bookmarks from html file; Firefox,
|
||||
Google Chrome and IE formats supported
|
||||
-m, --merge file merge bookmarks from another buku database
|
||||
-p, --print [N] show details of bookmark at DB index N
|
||||
-p, --print [...] show details of bookmark by DB index
|
||||
accepts indices and ranges
|
||||
show all bookmarks, if no arguments
|
||||
-f, --format N modify -p output. N=1: show only URL,
|
||||
N=2: show URL and tag, N=3: show only title
|
||||
@ -369,9 +370,9 @@ The last index is moved to the deleted index to keep the DB compact.
|
||||
$ buku -l 15
|
||||
$ buku -k 15
|
||||
The same number of iterations must be specified for one lock & unlock instance. Default is 8, if omitted.
|
||||
19. **Show details** of bookmark at index 15012014:
|
||||
19. **Show details** of bookmark at index 15012014 and ranges 20-30, 40-50:
|
||||
|
||||
$ buku -p 15012014
|
||||
$ buku -p 20-30 15012014 40-50
|
||||
20. **Show all** bookmarks with real index from database:
|
||||
|
||||
$ buku -p
|
||||
|
32
buku
32
buku
@ -1760,7 +1760,8 @@ if __name__ == '__main__':
|
||||
-i, --import file import bookmarks from html file; Firefox,
|
||||
Google Chrome and IE formats supported
|
||||
-m, --merge file merge bookmarks from another buku database
|
||||
-p, --print [N] show details of bookmark at DB index N
|
||||
-p, --print [...] show details of bookmark by DB index
|
||||
accepts indices and ranges
|
||||
show all bookmarks, if no arguments
|
||||
-f, --format N modify -p output. N=1: show only URL,
|
||||
N=2: show URL and tag, N=3: show only title
|
||||
@ -1779,8 +1780,8 @@ if __name__ == '__main__':
|
||||
help=argparse.SUPPRESS)
|
||||
addarg('-m', '--merge', nargs=1, dest='merge', metavar='file',
|
||||
help=argparse.SUPPRESS)
|
||||
addarg('-p', '--print', nargs='?', dest='printindex', type=int, const=0,
|
||||
metavar='N', help=argparse.SUPPRESS)
|
||||
addarg('-p', '--print', nargs='*', dest='print', metavar='N',
|
||||
help=argparse.SUPPRESS)
|
||||
addarg('-f', '--format', dest='showOpt', type=int, default=0,
|
||||
choices=[1, 2, 3], metavar='N', help=argparse.SUPPRESS)
|
||||
addarg('-r', '--replace', nargs='+', dest='replace',
|
||||
@ -1947,12 +1948,25 @@ if __name__ == '__main__':
|
||||
except ValueError as e:
|
||||
logger.error('Incorrect index or range')
|
||||
|
||||
# Print all records
|
||||
if args.printindex is not None:
|
||||
if args.printindex < 0:
|
||||
logger.error('Index must be >= 0')
|
||||
bdb.close_quit(1)
|
||||
bdb.print_bookmark(args.printindex)
|
||||
# Print records
|
||||
if args.print is not None:
|
||||
if len(args.print) == 0:
|
||||
bdb.print_bookmark(0)
|
||||
else:
|
||||
for idx in args.print:
|
||||
if is_int(idx):
|
||||
bdb.print_bookmark(int(idx))
|
||||
elif '-' in idx and is_int(idx.split('-')[0]) \
|
||||
and is_int(idx.split('-')[1]):
|
||||
lower = int(idx.split('-')[0])
|
||||
upper = int(idx.split('-')[1])
|
||||
if lower > upper:
|
||||
lower, upper = upper, lower
|
||||
for _id in range(lower, upper + 1):
|
||||
bdb.print_bookmark(_id)
|
||||
else:
|
||||
logger.error('Invalid index or range')
|
||||
bdb.close_quit(1)
|
||||
|
||||
# Replace a tag in DB
|
||||
if args.replace is not None:
|
||||
|
12
buku.1
12
buku.1
@ -109,12 +109,8 @@ Import bookmarks exported from Firefox, Google Chrome or IE in HTML format.
|
||||
.BI \-m " " \--merge " file"
|
||||
Merge bookmarks from another Buku database file.
|
||||
.TP
|
||||
.BI \-p " " \--print " [N]"
|
||||
Show details (URL, title and tags) of bookmark record stored at index
|
||||
.I N
|
||||
in DB. If
|
||||
.I N
|
||||
is omitted, all records with actual index from DB are shown.
|
||||
.BI \-p " " \--print " [...]"
|
||||
Show details (DB index, URL, title, tags and comment) of bookmark record by DB index. If no arguments, all records with actual index from DB are shown. Accepts hyphenated ranges and space-separated indices.
|
||||
.TP
|
||||
.BI \-f " " \--format " N"
|
||||
Show selective monochrome output. Works with -p. Useful for creating batch update scripts.
|
||||
@ -331,11 +327,11 @@ List \fBall unique tags\fR alphabetically:
|
||||
The same number of iterations must be specified for one lock & unlock instance. Default is 8, if omitted.
|
||||
.PP
|
||||
.IP 19. 4
|
||||
\fBShow details\fR of bookmark at index 15012014:
|
||||
\fBShow details\fR of bookmarks at index 15012014 and ranges 20-30, 40-50:
|
||||
.PP
|
||||
.EX
|
||||
.IP
|
||||
.B buku -p 15012014
|
||||
.B buku -p 20-30 15012014 40-50
|
||||
.PP
|
||||
.IP 20. 4
|
||||
\fBShow all\fR bookmarks with real index from database:
|
||||
|
Loading…
x
Reference in New Issue
Block a user