pr: Add --nostdin, to disable TTY detection
PATCH 1/1 pr: Add --nostdin, to disable TTY detection
I'm running b4 from a bash script that does all sorts of wacky stuff to try and talk to the Yubikey, which causes "b4 pr" to think I'm trying to pass it message IDs from standard in when I'm actually trying to do some via positional arguments. This adds a --nostdin command-line argument to turn off the automatic TTY-based detection and just force positional arguments.
---
I added this to b4.5.rst, not sure if that was the right place to put it. I noticed some other arguments in the source that don't appear to be documented in there.
--- b4/command.py | 2 ++ b4/pr.py | 2 +- man/b4.5.rst | 1 + 3 files changed, 4 insertions(+), 1 deletion(-)
b4/command.py +2 -0
@@ -194,6 +194,8 @@ def cmd(): 'the identity must match a [sendemail "identity"] config section')) sp_pr.add_argument('--dry-run', dest='dryrun', action='store_true', default=False, help='Force a --dry-run on git-send-email invocation (use with -s)') + sp_pr.add_argument('--nostdin', dest='nostdin', action='store_true', default=False, + help="Disable TTY detection for stdin.") sp_pr.add_argument('msgid', nargs='?', help='Message ID to process, or pipe a raw message') sp_pr.set_defaults(func=cmd_pr)
b4/pr.py +1 -1
@@ -472,7 +472,7 @@ def main(cmdargs): gitdir = cmdargs.gitdir lmsg = None - if not sys.stdin.isatty(): + if not sys.stdin.isatty() and not cmdargs.nostdin: logger.debug('Getting PR message from stdin') msg = email.message_from_bytes(sys.stdin.buffer.read()) cmdargs.msgid = b4.LoreMessage.get_clean_msgid(msg)
man/b4.5.rst +1 -0
@@ -253,6 +253,7 @@ optional arguments: -l, --retrieve-links Attempt to retrieve any Link: URLs (use with -e) -f MAILFROM, --from-addr MAILFROM Use this From: in exploded messages (use with -e) + --nostdin Disable TTY detection for stdin. *Example*: b4 pr 202003292120.2BDCB41@keescook
Signature · 1 line
2.38.0
Quoted 6 lines · Palmer Dabbelt
I'm running b4 from a bash script that does all sorts of wacky stuff to try and talk to the Yubikey, which causes "b4 pr" to think I'm trying to pass it message IDs from standard in when I'm actually trying to do some via positional arguments. This adds a --nostdin command-line argument to turn off the automatic TTY-based detection and just force positional arguments.
I didn't take this patch directly, because I wanted to implement this on the global level instead of just for PR (since we do TTY detection in multiple places). The end-result is very similar to what you need, you just have to put the flag before the subcommand, e.g.:
b4 --no-stdin pr [...]
Thank you for the suggestion.
-K