Made -i option independent of -a.
Signed-off-by: Arun Prakash Jana <engineerarun@gmail.com>
This commit is contained in:
parent
5b38f11b1a
commit
d4921362af
@ -72,12 +72,12 @@ Options
|
|||||||
-a URL tag 1, tag 2, ... add URL as bookmark with comma separated tags
|
-a URL tag 1, tag 2, ... add URL as bookmark with comma separated tags
|
||||||
-d N delete entry at index N
|
-d N delete entry at index N
|
||||||
-D delete ALL bookmarks
|
-D delete ALL bookmarks
|
||||||
-i N add entry at index N, works with -a, use to fill deleted index
|
-i N insert entry at index N, useful to fill deleted index
|
||||||
-p N show details of bookmark record at index N
|
-p N show details of bookmark record at index N
|
||||||
-P show all bookmarks along with real index from database
|
-P show all bookmarks along with real index from database
|
||||||
-s keyword(s) search all bookmarks for a (partial) tag or each keyword
|
-s keyword(s) search all bookmarks for a (partial) tag or each keyword
|
||||||
-u N update entry at index N (from output of -p)
|
-u N update entry at index N (from output of -P)
|
||||||
-w fetch title info from web, works with -a or -u
|
-w fetch title info from web, works with -a, -i, -u
|
||||||
-z show debug information
|
-z show debug information
|
||||||
you can either add or update or delete in one instance
|
you can either add or update or delete in one instance
|
||||||
any other option shows help and exits markit
|
any other option shows help and exits markit
|
||||||
@ -103,7 +103,7 @@ Updated</pre>
|
|||||||
5. Delete all bookmarks:
|
5. Delete all bookmarks:
|
||||||
<pre>$ markit -D</pre>
|
<pre>$ markit -D</pre>
|
||||||
6. Insert a bookmark at deleted index 15012014 (fails if index or URL exists in database):
|
6. Insert a bookmark at deleted index 15012014 (fails if index or URL exists in database):
|
||||||
<pre>$ markit -i 15012014 -a -w http://tuxdiary.com/about linux news, open source
|
<pre>$ markit -i 15012014 -w http://tuxdiary.com/about linux news, open source
|
||||||
Title: [A journey with WordPress | TuxDiary]
|
Title: [A journey with WordPress | TuxDiary]
|
||||||
Added at index 15012014</pre>
|
Added at index 15012014</pre>
|
||||||
This option is useful in filling deleted indices from database manually.
|
This option is useful in filling deleted indices from database manually.
|
||||||
|
54
markit
54
markit
@ -50,12 +50,12 @@ def usage():
|
|||||||
print(" -a URL tag 1, tag 2, ... add URL as bookmark with comma separated tags")
|
print(" -a URL tag 1, tag 2, ... add URL as bookmark with comma separated tags")
|
||||||
print(" -d N delete entry at index N")
|
print(" -d N delete entry at index N")
|
||||||
print(" -D delete ALL bookmarks")
|
print(" -D delete ALL bookmarks")
|
||||||
print(" -i N add entry at index N, works with -a, use to fill deleted index")
|
print(" -i N insert entry at index N, useful to fill deleted index")
|
||||||
print(" -p N show details of bookmark record at index N")
|
print(" -p N show details of bookmark record at index N")
|
||||||
print(" -P show all bookmarks along with real index from database")
|
print(" -P show all bookmarks along with real index from database")
|
||||||
print(" -s keyword(s) search all bookmarks for a (partial) tag or each keyword")
|
print(" -s keyword(s) search all bookmarks for a (partial) tag or each keyword")
|
||||||
print(" -u N update entry at index N (from output of -p)")
|
print(" -u N update entry at index N (from output of -P)")
|
||||||
print(" -w fetch title info from web, works with -a or -u")
|
print(" -w fetch title info from web, works with -a, -i, -u")
|
||||||
print(" -z show debug information")
|
print(" -z show debug information")
|
||||||
print(" you can either add or update or delete in one instance")
|
print(" you can either add or update or delete in one instance")
|
||||||
print(" any other option shows help and exits markit\n")
|
print(" any other option shows help and exits markit\n")
|
||||||
@ -275,21 +275,9 @@ def searchdb(cur, keywords):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_stderr = os.dup(2)
|
openurl = unquote(results[int(nav) - 1])
|
||||||
os.close(2)
|
openurl = openurl.replace("%22", "\"")
|
||||||
_stdout = os.dup(1)
|
browser_open(openurl)
|
||||||
os.close(1)
|
|
||||||
fd = os.open(os.devnull, os.O_RDWR)
|
|
||||||
os.dup2(fd, 2)
|
|
||||||
os.dup2(fd, 1)
|
|
||||||
try:
|
|
||||||
openurl = unquote(results[int(nav) - 1])
|
|
||||||
openurl = openurl.replace("%22", "\"")
|
|
||||||
webbrowser.open(openurl)
|
|
||||||
finally:
|
|
||||||
os.close(fd)
|
|
||||||
os.dup2(_stderr, 2)
|
|
||||||
os.dup2(_stdout, 1)
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print("Index out of bound")
|
print("Index out of bound")
|
||||||
else:
|
else:
|
||||||
@ -365,6 +353,26 @@ class BMHTMLParser(HTMLParser.HTMLParser):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Open a URL in browser
|
||||||
|
def browser_open(url):
|
||||||
|
_stderr = os.dup(2)
|
||||||
|
os.close(2)
|
||||||
|
_stdout = os.dup(1)
|
||||||
|
os.close(1)
|
||||||
|
fd = os.open(os.devnull, os.O_RDWR)
|
||||||
|
os.dup2(fd, 2)
|
||||||
|
os.dup2(fd, 1)
|
||||||
|
try:
|
||||||
|
webbrowser.open(url)
|
||||||
|
except Exception as e:
|
||||||
|
print("Browser Exception: %s" % e)
|
||||||
|
finally:
|
||||||
|
os.close(fd)
|
||||||
|
os.dup2(_stderr, 2)
|
||||||
|
os.dup2(_stdout, 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Main starts here
|
# Main starts here
|
||||||
# ----------------
|
# ----------------
|
||||||
optlist = None
|
optlist = None
|
||||||
@ -406,14 +414,18 @@ try:
|
|||||||
|
|
||||||
delete = True
|
delete = True
|
||||||
elif opt[0] == "-i":
|
elif opt[0] == "-i":
|
||||||
|
if update == True or delete == True:
|
||||||
|
print("You can either add or update or delete in one instance\n")
|
||||||
|
usage()
|
||||||
|
|
||||||
if not opt[1].isdigit():
|
if not opt[1].isdigit():
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
addindex = opt[1]
|
addindex = opt[1]
|
||||||
if int(addindex) <= 0:
|
if int(addindex) <= 0:
|
||||||
usage()
|
usage()
|
||||||
elif opt[0] == "-w":
|
|
||||||
online = True
|
addurl = True
|
||||||
elif opt[0] == "-p":
|
elif opt[0] == "-p":
|
||||||
if not opt[1].isdigit():
|
if not opt[1].isdigit():
|
||||||
usage()
|
usage()
|
||||||
@ -440,6 +452,8 @@ try:
|
|||||||
usage()
|
usage()
|
||||||
|
|
||||||
update = True
|
update = True
|
||||||
|
elif opt[0] == "-w":
|
||||||
|
online = True
|
||||||
elif opt[0] == "-z":
|
elif opt[0] == "-z":
|
||||||
debug = True
|
debug = True
|
||||||
except GetoptError as e:
|
except GetoptError as e:
|
||||||
|
6
markit.1
6
markit.1
@ -41,7 +41,7 @@ Delete ALL bookmarks.
|
|||||||
.BI \-i " N"
|
.BI \-i " N"
|
||||||
Add a new record at index
|
Add a new record at index
|
||||||
.I N
|
.I N
|
||||||
of the database. Works only if `-a` option is used. Use this option to fill blank indexes left by deleted bookmarks.
|
of the database. Use this option to fill blank indexes left by deleted bookmarks.
|
||||||
.TP
|
.TP
|
||||||
.BI \-p " N"
|
.BI \-p " N"
|
||||||
Show details of bookmark record stored at
|
Show details of bookmark record stored at
|
||||||
@ -57,10 +57,10 @@ Search bookmarks for a (partial) tag or keywords and show the results. Prompts t
|
|||||||
.BI \-u " N"
|
.BI \-u " N"
|
||||||
Update bookmark at index
|
Update bookmark at index
|
||||||
.I N
|
.I N
|
||||||
(as shown in `-p` output).
|
(as shown in `-P` output).
|
||||||
.TP
|
.TP
|
||||||
.BI \-w
|
.BI \-w
|
||||||
Fetch title data from the web. Works only with `-a` or `-u` options.
|
Fetch title data from the web. Works with `-a`, `-i` or `-u` options.
|
||||||
.TP
|
.TP
|
||||||
.BI \-z
|
.BI \-z
|
||||||
Enable debugging.
|
Enable debugging.
|
||||||
|
Loading…
Reference in New Issue
Block a user