From afadfcb2b419fb0e952cc6ffce1e244a027f0ddd Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 1 Jun 2015 19:46:19 -0400 Subject: [PATCH] Add short options (`-a`) to CLI. Updated release notes. --- docs/about/release-notes.md | 2 ++ mkdocs/cli.py | 40 ++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/docs/about/release-notes.md b/docs/about/release-notes.md index b822b7ec..3fb414ac 100644 --- a/docs/about/release-notes.md +++ b/docs/about/release-notes.md @@ -15,6 +15,8 @@ You can determine your currently installed version using `mkdocs --version`: ## Version 0.14.0 (2015-??-??) +* Add short options (`-a`) to most command line options. + ## Version 0.13.3 (2015-06-02) * Bugfix: Reduce validation error to a warning if the site_dir is within diff --git a/mkdocs/cli.py b/mkdocs/cli.py index 33b321c8..e7a1591c 100644 --- a/mkdocs/cli.py +++ b/mkdocs/cli.py @@ -45,9 +45,9 @@ remote_branch_help = ("The remote branch to commit to for Github Pages. This " "overrides the value specified in config") -@click.group() -@click.option('--verbose', is_flag=True, help="Enable verbose output") -@click.version_option(__version__) +@click.group(context_settings={'help_option_names': ['-h', '--help']}) +@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output") +@click.version_option(__version__, '-V', '--version') def cli(verbose): """ MkDocs - Project documentation with Markdown. @@ -62,10 +62,10 @@ def cli(verbose): @cli.command(name="serve") -@click.option('--config-file', type=click.File('rb'), help=config_file_help) -@click.option('--dev-addr', help=dev_addr_help, metavar='') -@click.option('--strict', is_flag=True, help=strict_help) -@click.option('--theme', type=click.Choice(theme_choices), help=theme_help) +@click.option('-f', '--config-file', type=click.File('rb'), help=config_file_help) +@click.option('-a', '--dev-addr', help=dev_addr_help, metavar='') +@click.option('-s', '--strict', is_flag=True, help=strict_help) +@click.option('-t', '--theme', type=click.Choice(theme_choices), help=theme_help) @click.option('--livereload/--no-livereload', default=True, help=reload_help) def serve_command(dev_addr, config_file, strict, theme, livereload): """Run the builtin development server""" @@ -86,11 +86,11 @@ def serve_command(dev_addr, config_file, strict, theme, livereload): @cli.command(name="build") -@click.option('--clean', is_flag=True, help=clean_help) -@click.option('--config-file', type=click.File('rb'), help=config_file_help) -@click.option('--strict', is_flag=True, help=strict_help) -@click.option('--theme', type=click.Choice(theme_choices), help=theme_help) -@click.option('--site-dir', type=click.Path(), help=site_dir_help) +@click.option('-c', '--clean', is_flag=True, help=clean_help) +@click.option('-f', '--config-file', type=click.File('rb'), help=config_file_help) +@click.option('-s', '--strict', is_flag=True, help=strict_help) +@click.option('-t', '--theme', type=click.Choice(theme_choices), help=theme_help) +@click.option('-d', '--site-dir', type=click.Path(), help=site_dir_help) def build_command(clean, config_file, strict, theme, site_dir): """Build the MkDocs documentation""" try: @@ -106,10 +106,10 @@ def build_command(clean, config_file, strict, theme, site_dir): @cli.command(name="json") -@click.option('--clean', is_flag=True, help=clean_help) -@click.option('--config-file', type=click.File('rb'), help=config_file_help) -@click.option('--strict', is_flag=True, help=strict_help) -@click.option('--site-dir', type=click.Path(), help=site_dir_help) +@click.option('-c', '--clean', is_flag=True, help=clean_help) +@click.option('-f', '--config-file', type=click.File('rb'), help=config_file_help) +@click.option('-s', '--strict', is_flag=True, help=strict_help) +@click.option('-d', '--site-dir', type=click.Path(), help=site_dir_help) def json_command(clean, config_file, strict, site_dir): """Build the MkDocs documentation to JSON files @@ -135,10 +135,10 @@ def json_command(clean, config_file, strict, site_dir): @cli.command(name="gh-deploy") -@click.option('--clean', is_flag=True, help=clean_help) -@click.option('--config-file', type=click.File('rb'), help=config_file_help) -@click.option('--message', '-m', help=commit_message_help) -@click.option('--remote-branch', '-b', help=remote_branch_help) +@click.option('-c', '--clean', is_flag=True, help=clean_help) +@click.option('-f', '--config-file', type=click.File('rb'), help=config_file_help) +@click.option('-m', '--message', help=commit_message_help) +@click.option('-b', '--remote-branch', help=remote_branch_help) def gh_deploy_command(config_file, clean, message, remote_branch): """Deply your documentation to GitHub Pages""" try: