Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add arguments to cmd_new.py to allow no input creation of commands #92

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions keep/commands/cmd_new.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import click
from keep import cli, utils

@click.command('new', short_help='Saves a new command.')
@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):
def cli(ctx, cmd, desc, alias):
"""Saves a new command"""
cmd = click.prompt('Command')
desc = click.prompt('Description ')
alias = click.prompt('Alias (optional)', default='')
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))
utils.log(ctx, "Saved the new command - {} - with the description - {}.".format(cmd, desc))