Skip to content

Overview

Run it

The simplest example
cmdcmp --file config.yaml --shell-type bash
Help
$ cmdcomp --help
Usage: cmdcomp [-h] [--version] [--verbose | --no-verbose] --file FILE
               --shell-type {bash,zsh} [--output-file OUTPUT_FILE]

shell completion file generator.

Options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --verbose, --no-verbose
                        output verbose log.
  --file, --config, -f FILE
                        config file path. supported formats are ".json",
                        ".yaml", ".toml" and ".jinja".
  --shell-type {bash,zsh}
                        target shell type.
  --output-file, -o OUTPUT_FILE
                        output file path. default is stdout.

Config

cmdcomp automatically generates a completion file according to the contents of the configuration file.

The overall structure of the configuration file is shown below.

cmdcomp:
  version: "2"
app:
  {{ App }}
root:
  {{ Command }}

More detailed information is given in the next section.

Please refer to JSON Schema for exact schema information.

Tip

jinja is also supported.

This is useful when you want to group duplicate settings into a variable.

config.yaml.jinja2
{%- set app_name = "mycli" -%}
cmdcomp:
  version: "2"
app:
  name: {{ app_name }}
root:
  arguments:
    --help:
cmdcomp --file config.yaml.jinja2 --shell-type bash

Tip

You can use json yaml toml for the format of the config file, but I recommend yaml for configuration.

The yaml language server gives the best development experience as an extension available for VSCode.

I have added the following configuration to VSCode, which makes it easier to write configuration files.

.vscode/settings.json
{
    "yaml.schemas": {
        "https://raw.githubusercontent.com/yassun7010/cmdcomp/main/docs/config.schema.json": "*_cmdcomp.yaml"
    },
}