Merge -P with -p. Now -P is -p 0.

This commit is contained in:
Arun Prakash Jana 2016-04-20 20:39:18 +05:30
parent 198ff40d50
commit 08fb03eec1
No known key found for this signature in database
GPG Key ID: C0A712ED95043DCB
3 changed files with 20 additions and 28 deletions

View File

@ -121,7 +121,7 @@ You may need to use `sudo` with `PREFIX` depending on your permissions on destin
General options General options
-a URL [tags] add URL as bookmark with comma separated tags -a URL [tags] add URL as bookmark with comma separated tags
-d N delete entry at DB index N (from -P), move last entry to N -d N delete entry at DB index N (from -p 0), move last entry to N
-g list all tags alphabetically -g list all tags alphabetically
-m title manually specify the title, for -a, -i, -u -m title manually specify the title, for -a, -i, -u
-s keyword(s) search bookmarks for any keyword -s keyword(s) search bookmarks for any keyword
@ -137,12 +137,11 @@ You may need to use `sudo` with `PREFIX` depending on your permissions on destin
-k decrypt (unlock) database file -k decrypt (unlock) database file
-l encrypt (lock) database file -l encrypt (lock) database file
-o N open URL at DB index N in browser -o N open URL at DB index N in browser
-p N show details of bookmark record at DB index N -p N show details of bookmark record at DB index N (0 for all)
-P show all bookmarks along with index from DB
-r oldtag [newtag] replace oldtag with newtag, delete oldtag if newtag empty -r oldtag [newtag] replace oldtag with newtag, delete oldtag if newtag empty
-R refresh title from web for all bookmarks, update if non-empty -R refresh title from web for all bookmarks, update if non-empty
-t N use N (> 0) hash iterations to generate key, for -k, -l -t N use N (> 0) hash iterations to generate key, for -k, -l
-x N modify -P behaviour, N=1: show only URL, N=2: show URL and tag -x N modify -p behaviour, N=1: show only URL, N=2: show URL and tag
-z show debug information -z show debug information
Keys Keys
@ -215,7 +214,7 @@ The last index is moved to the deleted index to keep the DB compact.
$ buku -p 15012014 $ buku -p 15012014
12. **Show all** bookmarks with real index from database: 12. **Show all** bookmarks with real index from database:
$ buku -P $ buku -p 0
13. **Open URL** at index 15012014 in browser: 13. **Open URL** at index 15012014 in browser:
$ buku -o 15012014 $ buku -o 15012014
@ -261,7 +260,7 @@ Use the `-u` option to add title or tags to those entries, if you want to.
Make the script executable and run to batch add bookmarks. Make the script executable and run to batch add bookmarks.
3. To **update selected URLs** (refresh) along with your tags, first get the unformatted selective output with URL and tags: 3. To **update selected URLs** (refresh) along with your tags, first get the unformatted selective output with URL and tags:
$ buku -P -x 2 | tee myurls $ buku -p 0 -x 2 | tee myurls
Remove the lines you don't need. Add `buku -wu ` in front of all the other lines (check TIP below). Should look like: Remove the lines you don't need. Add `buku -wu ` in front of all the other lines (check TIP below). Should look like:
#!/bin/bash #!/bin/bash

24
buku
View File

@ -59,7 +59,6 @@ online = False # Fetch title from web
delete = False # Delete bookmark(s) delete = False # Delete bookmark(s)
empty = False # List all bookmarks with no title or tag empty = False # List all bookmarks with no title or tag
openurl = None # Open URL in browser openurl = None # Open URL in browser
show = False # Show all details of a bookmark
showindex = None # Index of bookmark to show showindex = None # Index of bookmark to show
showOpt = 0 # Modify show. 1: show only URL, 2: show URL and tag showOpt = 0 # Modify show. 1: show only URL, 2: show URL and tag
showTags = False # List all unique tags showTags = False # List all unique tags
@ -601,7 +600,7 @@ def printdb(cur, index, empty=False):
global jsonOutput global jsonOutput
resultset = None resultset = None
if index == None: # Show all entries if int(index) == 0: # Show all entries
if empty == False: if empty == False:
cur.execute('SELECT * FROM bookmarks') cur.execute('SELECT * FROM bookmarks')
resultset = cur.fetchall() resultset = cur.fetchall()
@ -962,7 +961,7 @@ def usage():
"General options\n" "General options\n"
" -a URL [tags] add URL as bookmark with comma separated tags\n" " -a URL [tags] add URL as bookmark with comma separated tags\n"
" -d N delete entry at DB index N (from -P), move last entry to N\n" " -d N delete entry at DB index N (from -p 0), move last entry to N\n"
" -g list all tags alphabetically\n" " -g list all tags alphabetically\n"
" -m title manually specify the title, for -a, -i, -u\n" " -m title manually specify the title, for -a, -i, -u\n"
" -s keyword(s) search bookmarks for any keyword\n" " -s keyword(s) search bookmarks for any keyword\n"
@ -978,12 +977,11 @@ def usage():
" -k decrypt (unlock) database file\n" " -k decrypt (unlock) database file\n"
" -l encrypt (lock) database file\n" " -l encrypt (lock) database file\n"
" -o N open URL at DB index N in browser\n" " -o N open URL at DB index N in browser\n"
" -p N show details of bookmark record at DB index N\n" " -p N show details of bookmark record at DB index N (0 for all)\n"
" -P show all bookmarks along with index from DB\n"
" -r oldtag [newtag] replace oldtag with newtag, delete oldtag if newtag empty\n" " -r oldtag [newtag] replace oldtag with newtag, delete oldtag if newtag empty\n"
" -R refresh title from web for all bookmarks, update if non-empty\n" " -R refresh title from web for all bookmarks, update if non-empty\n"
" -t N use N (> 0) hash iterations to generate key, for -k, -l\n" " -t N use N (> 0) hash iterations to generate key, for -k, -l\n"
" -x N modify -P behaviour, N=1: show only URL, N=2: show URL and tag\n" " -x N modify -p behaviour, N=1: show only URL, N=2: show URL and tag\n"
" -z show debug information\n\n" " -z show debug information\n\n"
"Keys\n" "Keys\n"
@ -1022,9 +1020,9 @@ if len(sys.argv) < 2:
try: try:
if len(pipeargs) > 0: if len(pipeargs) > 0:
optlist, keywords = getopt(pipeargs[1:], "d:i:m:o:p:t:u:x:aDegjklPRrsSwz") optlist, keywords = getopt(pipeargs[1:], "d:i:m:o:p:t:u:x:aDegjklRrsSwz")
else: else:
optlist, keywords = getopt(sys.argv[1:], "d:i:m:o:p:t:u:x:aDegjklPRrsSwz") optlist, keywords = getopt(sys.argv[1:], "d:i:m:o:p:t:u:x:aDegjklRrsSwz")
if len(optlist) < 1: if len(optlist) < 1:
usage() usage()
@ -1099,12 +1097,8 @@ try:
usage() usage()
showindex = opt[1] showindex = opt[1]
if int(showindex) <= 0: if int(showindex) < 0:
usage() usage()
show = True
elif opt[0] == "-P":
show = True
elif opt[0] == "-R": elif opt[0] == "-R":
if addurl == True or delete == True: if addurl == True or delete == True:
print("You can either add or update or delete in one instance\n") print("You can either add or update or delete in one instance\n")
@ -1217,7 +1211,7 @@ if search == True:
searchdb(cur, keywords) searchdb(cur, keywords)
# Print all records # Print all records
if show == True: if showindex is not None:
printdb(cur, showindex) printdb(cur, showindex)
# Show all unique tags # Show all unique tags
@ -1225,7 +1219,7 @@ if showTags == True:
showUniqueTags(cur) showUniqueTags(cur)
if empty == True: if empty == True:
printdb(cur, None, empty) printdb(cur, 0, empty)
# Open URL in browser # Open URL in browser
if openurl != None: if openurl != None:

13
buku.1
View File

@ -45,7 +45,7 @@ along with comma separated tags. A tag can have multiple words. The same URL can
.BI \-d " N" .BI \-d " N"
Delete bookmark at index Delete bookmark at index
.I N .I N
in DB (from -P output). in DB (from -p 0 output).
.TP .TP
.B \-D .B \-D
Delete ALL bookmarks. Delete ALL bookmarks.
@ -62,7 +62,7 @@ Add a new record at free index
in DB. in DB.
.TP .TP
.B \-j .B \-j
Output data formatted as json (works with -P, -p and -s) Output data formatted as json (works with -p and -s)
.TP .TP
.B \-k .B \-k
Decrypt (unlock) the DB file. Decrypt (unlock) the DB file.
@ -82,9 +82,8 @@ in browser.
Show details of bookmark record stored at index Show details of bookmark record stored at index
.I N .I N
in DB. in DB.
.TP .I N
.B \-P = 0 shows all records with actual index from DB. Shows URL, title and tags.
Show all bookmark records from the DB along with actual index. Shows URL, title and tags.
.TP .TP
.B \-R .B \-R
Refresh titles for all bookmarks from the web. Titles are updated only if non-empty. Indexes, URLs and tags are retained. Refresh titles for all bookmarks from the web. Titles are updated only if non-empty. Indexes, URLs and tags are retained.
@ -109,7 +108,7 @@ in DB.
Fetch title data from the web. Works with -a, -i or -u options. Fetch title data from the web. Works with -a, -i or -u options.
.TP .TP
.BI \-x " N" .BI \-x " N"
Show selective monochrome output. Works with -P. If Show selective monochrome output. Works with -p. If
.I N .I N
= 1, only URL is shown. If = 1, only URL is shown. If
.I N .I N
@ -234,7 +233,7 @@ List \fBall unique tags\fR alphabetically:
.PP .PP
.EX .EX
.IP .IP
.B buku -P .B buku -p 0
.PP .PP
.IP 13. 4 .IP 13. 4
\fBOpen URL\fR at index 15012014 in browser: \fBOpen URL\fR at index 15012014 in browser: