File: cmd_completion.py

package info (click to toggle)
python-keep 2.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 184 kB
  • sloc: python: 542; sh: 25; makefile: 3
file content (20 lines) | stat: -rw-r--r-- 600 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from shlex import quote

import click
from keep import cli, utils


@click.command('completion', short_help='Command completion helper.')
@click.option('--bash', 'shell', flag_value='bash', default=True)
@click.option('--zsh', 'shell', flag_value='zsh')
@cli.pass_context
def cli(ctx, shell):
    """Completion helpers for keep"""
    commands = utils.read_commands()

    if shell == 'zsh':
        for cmd, fields in commands.items():
            print("{cmd}:{desc}".format(cmd=cmd, desc=fields['desc']))
    elif shell == 'bash':
        for cmd in commands.keys():
            print(quote(cmd))