DannyBen/bashly

View on GitHub
examples/completions/src/bashly.yml

Summary

Maintainability
Test Coverage
name: cli
help: Sample application with bash completions
version: 0.1.0

# All commands and flags will be automatically used in the completions script
commands:
- name: completions
  help: |-
    Generate bash completions
    Usage: eval "\$(cli completions)"

- name: download
  alias: d
  help: Download a file

  # Adding custom completions for a command. In this case, typing
  # `cli download <TAB>` will suggest files.
  completions:
  - <file>

  args:
  - name: source
    required: true
    help: URL to download from
  - name: target
    help: "Target filename (default: same as source)"

  flags:
  - long: --force
    short: -f
    help: Overwrite existing files
  - long: --handler
    arg: command

    # The allowed flag arg whitelist will be added automatically. In this case,
    # typing `cli download --handler <tab>` will suggest curl or wget
    allowed:
      - curl
      - wget

    default: curl

  examples:
  - cli download example.com
  - cli download example.com ./output -f

  environment_variables:
  - name: default_target_location
    help: Set the default location to download to

- name: upload
  alias: u
  help: Upload a file

  # Add directories and users to the suggested completions.
  completions:
    - <directory>
    - <user>

  args:
  - name: source
    required: true
    help: File to upload

    # The allowed argument whitelist will be added automatically. In this case
    # typing `cli upload <TAB>` will suggest these files.
    allowed:
      - README.md
      - CHANGELOG.md

  flags:
  - long: --user
    short: -u
    arg: user
    help: Username to use for logging in
    required: true

    # Adding completions to a flag with an argument will add it to the suggested
    # words list. In this case typing `cli upload --user <TAB>` will suggest
    # users.
    completions:
      - <user>

  - long: --password
    short: -p
    arg: password
    help: Password to use for logging in