diff --git a/README.md b/README.md index 1037411..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) ----------------- @@ -19,6 +21,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 07df3bc..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): @@ -124,12 +129,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) 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)