File: cmd_new.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 (19 lines) | stat: -rw-r--r-- 694 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import click
from keep import cli, utils

@click.command("new", short_help="Saves a new command.")
@click.option("--cmd", help="The command to save")
@click.option("--desc", help="The description of the command")
@click.option("--alias", default="", help="The alias of the command")
@cli.pass_context
def cli(ctx, cmd, desc, alias):
    """Saves a new command"""
    if not cmd:
        cmd = click.prompt("Command")
    if not desc:
        desc = click.prompt("Description")
    if not alias:
        alias = click.prompt("Alias (optional)", default="")
    utils.save_command(cmd, desc, alias)

    utils.log(ctx, "Saved the new command - {} - with the description - {}.".format(cmd, desc))