From ef54d3a58b32a61aac51dd4e0f3ac92927ab7bde Mon Sep 17 00:00:00 2001 From: Mauricio Jost Date: Thu, 23 Jul 2020 01:59:52 +0200 Subject: [PATCH 1/3] Help user on login and workaround parser bug Parser bug: https://bugs.python.org/issue16308 --- keep | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/keep b/keep index 07df3bc..bdc1b81 100755 --- a/keep +++ b/keep @@ -124,12 +124,20 @@ if not logged_in: token = keep.getMasterToken() keyring.set_password('google-keep-token', config['username'], token) logger.info('Success') - except gkeepapi.exception.LoginException: - logger.info('Login failed') - -if not logged_in: - logger.error('Failed to authenticate') - sys.exit(1) - - -args.func(args, keep, config) + except gkeepapi.exception.LoginException as err: + logger.error('Login failed') + logger.error('Ensure you have:') + logger.error('- entered correctly your password for the account: ' + config['username']) + logger.error('- allowed less secured apps at: https://myaccount.google.com/lesssecureapps?pli=0 (*)') + logger.error('- unlocked the account via captcha: https://accounts.google.com/b/0/DisplayUnlockCaptcha (*)') + logger.error('') + logger.error('(*) where 0 is your Google account id, may be different if multiple logins, adapt it') + raise err + + + +try: + func = args.func +except AttributeError: + parser.error("Invalid arguments!") +func(args, keep, config) From 929f9d236d82a737fd730eb7f76a24de8fbf36ea Mon Sep 17 00:00:00 2001 From: Mauricio Jost Date: Thu, 23 Jul 2020 02:24:23 +0200 Subject: [PATCH 2/3] Add notes too --- README.md | 13 +++++++++++++ keep | 5 +++++ keep_cli/commands.py | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 1037411..2d207b8 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,19 @@ Running $ ./keep ``` +Features +-------- + +The CLI allows: + +- [x] Adding a note (basic) +- [x] Searching a note (basic) +- [x] Modifying an existent note (basic) + +The TUI allows: + +**TBC** + Todo ---- diff --git a/keep b/keep index bdc1b81..cd90ad6 100755 --- a/keep +++ b/keep @@ -70,6 +70,11 @@ set_parser.add_argument('--title', type=str, help='Set title of a note') set_parser.add_argument('--text', type=str, help='Set body of a note') set_parser.set_defaults(func=commands.set) +add_parser = subparsers.add_parser('add', help='Add a new note') +add_parser.add_argument('--title', type=str, help='The title of the note') +add_parser.add_argument('--text', type=str, help='The body of the note') +add_parser.set_defaults(func=commands.add) + args = parser.parse_args() if not os.path.isdir(args.config_dir): diff --git a/keep_cli/commands.py b/keep_cli/commands.py index 339cd4b..896e2bb 100644 --- a/keep_cli/commands.py +++ b/keep_cli/commands.py @@ -75,3 +75,7 @@ def set(args: argparse.Namespace, keep: gkeepapi.Keep, config: dict): note.text = args.text _sync(args, keep, config, True) + +def add(args: argparse.Namespace, keep: gkeepapi.Keep, config: dict): + keep.createNote(args.title, args.text) + _sync(args, keep, config, True) From 52ce7c117b3e991d33e944329cb6bfd79189f111 Mon Sep 17 00:00:00 2001 From: Mauricio Jost Date: Thu, 23 Jul 2020 02:27:48 +0200 Subject: [PATCH 3/3] Mention the core in the README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2d207b8..4872707 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Google Keep frontend for terminals. This is alpha quality code! Don't use in production. The project is under active development, so feel free to open an issue if you have questions, see any bugs or have a feature request. PRs are welcome too! +This project is a client based on [gkeepapi](https://github.com/kiwiz/gkeepapi). + Screen cast (WIP) -----------------