Fix #513: option --nostdin: do not attempt to read stdin
No need to add the option to auto-completion scripts as it does not apply to manual input from a tty.
This commit is contained in:
parent
8442bb8c22
commit
5b171fc9b3
@ -244,6 +244,7 @@ POWER TOYS:
|
|||||||
--cached index|URL browse a cached page from Wayback Machine
|
--cached index|URL browse a cached page from Wayback Machine
|
||||||
--suggest show similar tags when adding bookmarks
|
--suggest show similar tags when adding bookmarks
|
||||||
--tacit reduce verbosity, skip some confirmations
|
--tacit reduce verbosity, skip some confirmations
|
||||||
|
--nostdin do not wait for input (must be first arg)
|
||||||
--threads N max network connections in full refresh
|
--threads N max network connections in full refresh
|
||||||
default N=4, min N=1, max N=10
|
default N=4, min N=1, max N=10
|
||||||
-V check latest upstream version available
|
-V check latest upstream version available
|
||||||
|
21
buku
21
buku
@ -4914,7 +4914,7 @@ def piped_input(argv, pipeargs=None):
|
|||||||
"""
|
"""
|
||||||
if not sys.stdin.isatty():
|
if not sys.stdin.isatty():
|
||||||
pipeargs += argv
|
pipeargs += argv
|
||||||
print('waiting for input')
|
print('buku: waiting for input (unexpected? try --nostdin)')
|
||||||
for s in sys.stdin:
|
for s in sys.stdin:
|
||||||
pipeargs += s.split()
|
pipeargs += s.split()
|
||||||
|
|
||||||
@ -5043,14 +5043,15 @@ def main():
|
|||||||
pipeargs = []
|
pipeargs = []
|
||||||
colorstr_env = os.getenv('BUKU_COLORS')
|
colorstr_env = os.getenv('BUKU_COLORS')
|
||||||
|
|
||||||
try:
|
if len(sys.argv) >= 2 and sys.argv[1] != '--nostdin':
|
||||||
piped_input(sys.argv, pipeargs)
|
try:
|
||||||
except KeyboardInterrupt:
|
piped_input(sys.argv, pipeargs)
|
||||||
pass
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
||||||
# If piped input, set argument vector
|
# If piped input, set argument vector
|
||||||
if pipeargs:
|
if pipeargs:
|
||||||
sys.argv = pipeargs
|
sys.argv = pipeargs
|
||||||
|
|
||||||
# Setup custom argument parser
|
# Setup custom argument parser
|
||||||
argparser = ExtendedArgumentParser(
|
argparser = ExtendedArgumentParser(
|
||||||
@ -5203,6 +5204,7 @@ POSITIONAL ARGUMENTS:
|
|||||||
--cached index|URL browse a cached page from Wayback Machine
|
--cached index|URL browse a cached page from Wayback Machine
|
||||||
--suggest show similar tags when adding bookmarks
|
--suggest show similar tags when adding bookmarks
|
||||||
--tacit reduce verbosity, skip some confirmations
|
--tacit reduce verbosity, skip some confirmations
|
||||||
|
--nostdin do not wait for input (must be first arg)
|
||||||
--threads N max network connections in full refresh
|
--threads N max network connections in full refresh
|
||||||
default N=4, min N=1, max N=10
|
default N=4, min N=1, max N=10
|
||||||
-V check latest upstream version available
|
-V check latest upstream version available
|
||||||
@ -5226,6 +5228,7 @@ POSITIONAL ARGUMENTS:
|
|||||||
addarg('--cached', nargs=1, help=hide)
|
addarg('--cached', nargs=1, help=hide)
|
||||||
addarg('--suggest', action='store_true', help=hide)
|
addarg('--suggest', action='store_true', help=hide)
|
||||||
addarg('--tacit', action='store_true', help=hide)
|
addarg('--tacit', action='store_true', help=hide)
|
||||||
|
addarg('--nostdin', action='store_true', help=hide)
|
||||||
addarg('--threads', type=int, default=4, choices=range(1, 11), help=hide)
|
addarg('--threads', type=int, default=4, choices=range(1, 11), help=hide)
|
||||||
addarg('-V', dest='upstream', action='store_true', help=hide)
|
addarg('-V', dest='upstream', action='store_true', help=hide)
|
||||||
addarg('-g', '--debug', action='store_true', help=hide)
|
addarg('-g', '--debug', action='store_true', help=hide)
|
||||||
@ -5291,7 +5294,7 @@ POSITIONAL ARGUMENTS:
|
|||||||
browse.override_text_browser = False
|
browse.override_text_browser = False
|
||||||
|
|
||||||
# Fallback to prompt if no arguments
|
# Fallback to prompt if no arguments
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) <= 2 and (len(sys.argv) == 1 or (len(sys.argv) == 2 and args.nostdin)):
|
||||||
bdb = BukuDb()
|
bdb = BukuDb()
|
||||||
prompt(bdb, None)
|
prompt(bdb, None)
|
||||||
bdb.close_quit(0)
|
bdb.close_quit(0)
|
||||||
|
3
buku.1
3
buku.1
@ -295,6 +295,9 @@ Show a list of similar tags to choose from when adding a new bookmark.
|
|||||||
.BI \--tacit
|
.BI \--tacit
|
||||||
Show lesser output. Reduces the verbosity of certain operations like add, update etc.
|
Show lesser output. Reduces the verbosity of certain operations like add, update etc.
|
||||||
.TP
|
.TP
|
||||||
|
.BI \--nostdin
|
||||||
|
Do not attempt to read data from standard input e.g. when the program is not executed from a tty.
|
||||||
|
.TP
|
||||||
.BI \--threads
|
.BI \--threads
|
||||||
Maximum number of parallel network connection threads to use during full DB refresh. By default 4 connections are spawned.
|
Maximum number of parallel network connection threads to use during full DB refresh. By default 4 connections are spawned.
|
||||||
.I N
|
.I N
|
||||||
|
Loading…
Reference in New Issue
Block a user