Skip to content

Commit

Permalink
Use default editor to edit a note
Browse files Browse the repository at this point in the history
  • Loading branch information
Drarig29 committed Jun 2, 2021
1 parent 051cb81 commit 4d7ced4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion google_keep_tasks/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
}
COLOR_NAMES = [color.name.lower() for color in gkeepapi.node.ColorValue]

placeholder = '__placeholder__'


def get_color(color):
if not color:
Expand Down Expand Up @@ -199,7 +201,7 @@ def get_note(ctx, **kwargs):
@notes.command('edit', options_metavar='[options]')
@click.option('--title', default=None, required=False, metavar='<new title>',
help='Change the note title')
@click.option('--text', default=None, required=False, metavar='<new_note_content>',
@click.option('--text', default=None, required=False, is_flag=False, flag_value=placeholder, metavar='[new_note_content]',
help='Change the note text')
@click.option('--filter-id', default=None, required=False, metavar='<id>',
help='Filter by id note. This is the preferred way to ensure editing the correct note')
Expand Down Expand Up @@ -231,6 +233,8 @@ def edit_note(ctx, title, text, color, labels, archived, pinned, filter_id, filt
if not note:
click.echo('The note was not found', err=True)
sys.exit(2)
if text == placeholder:
text = click.edit(note.text).strip()
updated = {}
boolean_nullables = ['archived', 'pinned'] # 3 state params
for param in ['title', 'text', 'color', 'labels'] + boolean_nullables:
Expand Down

0 comments on commit 4d7ced4

Please sign in to comment.