From 274c92a64b441297a323e2300a0f1c93de99bc1b Mon Sep 17 00:00:00 2001 From: cryzed Date: Fri, 17 Nov 2017 12:42:25 +0100 Subject: [PATCH 1/2] Add documentation additionally to the help page of qute-pass (complaint from the Arch wiki) --- misc/userscripts/qute-pass | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/misc/userscripts/qute-pass b/misc/userscripts/qute-pass index 1592d6349..4c6b1a17b 100755 --- a/misc/userscripts/qute-pass +++ b/misc/userscripts/qute-pass @@ -44,8 +44,16 @@ import sys import tldextract -argument_parser = argparse.ArgumentParser() -argument_parser.add_argument('url', nargs='?', default=os.environ['QUTE_URL']) +argument_parser = argparse.ArgumentParser(description=( + 'Insert login information using pass and a dmenu-provider (e.g. dmenu, rofi -dmenu, ...). A short ' + 'demonstration can be seen here: https://i.imgur.com/KN3XuZP.gif.'), usage=( + 'The domain of the site has to appear as a segment in the pass path, for example: "github.com/cryzed" or ' + '"websites/github.com". How the username and password are determined is freely configurable using the CLI ' + "arguments. The login information is inserted by emulating key events using qutebrowser's fake-key command in this " + 'manner: [USERNAME][PASSWORD], which is compatible with almost all login forms.'), epilog=( + "WARNING: The login details are viewable as plaintext in qutebrowser's debug log (qute://log) and might be shared " + 'if you decide to submit a crash report!')) +argument_parser.add_argument('url', nargs='?', default=os.getenv('QUTE_URL')) argument_parser.add_argument('--password-store', '-p', default=os.path.expanduser('~/.password-store'), help='Path to your pass password-store') argument_parser.add_argument('--username-pattern', '-u', default=r'.*/(.+)', @@ -71,6 +79,7 @@ stderr = functools.partial(print, file=sys.stderr) class ExitCodes(enum.IntEnum): SUCCESS = 0 + FAILURE = 1 # 1 is automatically used if Python throws an exception NO_PASS_CANDIDATES = 2 COULD_NOT_MATCH_USERNAME = 3 @@ -108,6 +117,10 @@ def dmenu(items, invocation, encoding): def main(arguments): + if not arguments.url: + argument_parser.print_help() + return ExitCodes.FAILURE + extract_result = tldextract.extract(arguments.url) # Expand potential ~ in paths, since this script won't be called from a shell that does it for us From d8887f12c03b74ec6778c04ad8c8895983c93336 Mon Sep 17 00:00:00 2001 From: cryzed Date: Fri, 17 Nov 2017 21:40:08 +0100 Subject: [PATCH 2/2] Deduplicate documentation --- misc/userscripts/qute-pass | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/misc/userscripts/qute-pass b/misc/userscripts/qute-pass index 4c6b1a17b..5bab9db93 100755 --- a/misc/userscripts/qute-pass +++ b/misc/userscripts/qute-pass @@ -17,20 +17,21 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +""" +Insert login information using pass and a dmenu-compatible application (e.g. dmenu, rofi -dmenu, ...). A short +demonstration can be seen here: https://i.imgur.com/KN3XuZP.gif. +""" -# Insert login information using pass and a dmenu-provider (e.g. dmenu, rofi -dmenu, ...). -# A short demonstration can be seen here: https://i.imgur.com/KN3XuZP.gif. -# -# The domain of the site has to appear as a segment in the pass path, for example: "github.com/cryzed" or -# "websites/github.com". How the username and password are determined is freely configurable using the CLI arguments. -# The login information is inserted by emulating key events using qutebrowser's fake-key command in this manner: -# [USERNAME][PASSWORD], which is compatible with almost all login forms. -# -# Dependencies: tldextract (Python 3 module), pass -# For issues and feedback please use: https://github.com/cryzed/qutebrowser-userscripts. -# -# WARNING: The login details are viewable as plaintext in qutebrowser's debug log (qute://log) and might be shared if -# you decide to submit a crash report! +USAGE = """The domain of the site has to appear as a segment in the pass path, for example: "github.com/cryzed" or +"websites/github.com". How the username and password are determined is freely configurable using the CLI arguments. The +login information is inserted by emulating key events using qutebrowser's fake-key command in this manner: +[USERNAME][PASSWORD], which is compatible with almost all login forms.""" + +EPILOG = """Dependencies: tldextract (Python 3 module), pass. +For issues and feedback please use: https://github.com/cryzed/qutebrowser-userscripts. + +WARNING: The login details are viewable as plaintext in qutebrowser's debug log (qute://log) and might be shared if +you decide to submit a crash report!""" import argparse import enum @@ -44,15 +45,7 @@ import sys import tldextract -argument_parser = argparse.ArgumentParser(description=( - 'Insert login information using pass and a dmenu-provider (e.g. dmenu, rofi -dmenu, ...). A short ' - 'demonstration can be seen here: https://i.imgur.com/KN3XuZP.gif.'), usage=( - 'The domain of the site has to appear as a segment in the pass path, for example: "github.com/cryzed" or ' - '"websites/github.com". How the username and password are determined is freely configurable using the CLI ' - "arguments. The login information is inserted by emulating key events using qutebrowser's fake-key command in this " - 'manner: [USERNAME][PASSWORD], which is compatible with almost all login forms.'), epilog=( - "WARNING: The login details are viewable as plaintext in qutebrowser's debug log (qute://log) and might be shared " - 'if you decide to submit a crash report!')) +argument_parser = argparse.ArgumentParser(description=__doc__, usage=USAGE, epilog=EPILOG) argument_parser.add_argument('url', nargs='?', default=os.getenv('QUTE_URL')) argument_parser.add_argument('--password-store', '-p', default=os.path.expanduser('~/.password-store'), help='Path to your pass password-store')