Skip to content

Argument

This item sets the completion candidates for each command argument.

Select Argument

If you want to choise several candidates, use select type argument.

cmdcomp:
  version: "2"
app:
  name: mycli
root:
  arguments:
    --format:
      type: select
      description: output format.
      options:
        - json
        - yaml
        - toml
[cmdcomp]
version = "2"

[app]
name = "mycli"

[root.arguments.--format]
type = "select"
description = "output format."
options = ["json", "yaml", "toml"]

File Argument

If you want the output to be a candidate for file path completion, the file type is recommended.

cmdcomp:
  version: "2"
app:
  name: mycli
root:
  arguments:
    --output:
      type: file
      description: output filename.
[cmdcomp]
version = "2"

[app]
name = "mycli"

[root.arguments.--output]
type = "file"
description = "output filename."

By default, it outputs completion candidates starting from the current directory of the shell, but you can change the starting directory by specifying base_path.

cmdcomp:
  version: "2"
app:
  name: mycli
root:
  arguments:
    --list:
      type: file
      description: list my command targets.
      base_path: $HOME/.mycmd/targets
[cmdcomp]
version = "2"

[app]
name = "mycli"

[root.arguments.--list]
type = "file"
description = "list my command targets."
base_path = "$HOME/.mycmd/targets"

For more complex conditions, such as outputting only files with a specific file extension, consider using the command type.

Command Argument

If you want to make the result of executing any command a completion candidate, use the command type.

cmdcomp:
  version: "2"
app:
  name: mycli
root:
  arguments:
    --start-date:
      type: command
      description: start date.
      execute: date +%Y-%m-%d
[cmdcomp]
version = "2"

[app]
name = "mycli"

[root.arguments.--start-date]
type = "command"
description = "start date."
execute = "date +%Y-%m-%d"