def list(ctx): """Print out a table with all notes.""" notes = [] for i, note in enumerate(ctx.data): if config.RELDATES: header = ['ID', 'Title', 'Age'] notes.append([i, note.title, note.format_age()]) else: header = ['ID', 'Title', 'Updated'] notes.append([i, note.title, note.format_updated()]) echo(str(Table(notes, headline=header)))
def show(ctx, key, lang): """Show a specific note.""" note = get_note(ctx.data, key) if lang and config.COLORS: content = highlight_(note.content.decode(), lang) elif lang and config.COLORS is False: echo_error('Color support is not enabled!') exit(1) else: content = note.content.decode() if ctx.no_header: output = content else: output = note.get_header() + '\n\n' + content echo(output, ctx.no_pager)
def all(ctx): """Print out all notes in the data directory.""" output = '' for i, note in enumerate(ctx.data): counter = '-- note {} --'.format(i) counter = click.style(counter, bold=True) if config.COLORS else counter output += '\n\n' output += counter output += '\n\n' if note.is_encrypted: output += 'Encrypted note!' output += '\n' else: if ctx.no_header: output += note.content.decode() else: output += note.get_header() output += '\n\n' output += note.content.decode() echo(output, ctx.no_pager)