Skip to content

Latest commit

 

History

History
164 lines (108 loc) · 2.27 KB

File metadata and controls

164 lines (108 loc) · 2.27 KB

Split Config Example

Demonstrates how to separate your bashly.yml into several files, and load configuration data from other YAML files, or directly from a YAML front matter in your code.

This example was generated with:

$ bashly init
$ bashly generate
# ... now edit all files in the src folder ...
$ bashly generate

bashly.yml

name: cli
help: Configuration splitting example
version: 0.1.0

commands:
  # Import a command that is defined in another YAML file
  - import: src/download_command.yml
  
  # Import a command that is defined in the front matter of its own shell
  # function.
  - import: src/upload_command.sh

src/download_command.yml

name: download
alias: d
help: Download a file

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

flags:
  import: src/common_flags.yml

src/upload_command.sh

# This is a YAML front matter describing the command
# It is imported to bashly.yml when running "bashly generate"

name: upload
alias: u
help: Upload a file
args:
- name: source
  required: true
  help: File to upload

flags:
  import: src/common_flags.yml

---
# Shell script starts here
inspect_args

src/common_flags.yml

- long: --force
  short: -f
  help: Overwrite existing files

Output

$ ./cli

cli - Configuration splitting example

Usage:
  cli COMMAND
  cli [COMMAND] --help | -h
  cli --version | -v

Commands:
  download   Download a file
  upload     Upload a file


$ ./cli download -h

cli download - Download a file

Alias: d

Usage:
  cli download SOURCE [TARGET] [OPTIONS]
  cli download --help | -h

Options:
  --force, -f
    Overwrite existing files

  --help, -h
    Show this help

Arguments:
  SOURCE
    URL to download from

  TARGET
    Target filename (default: same as source)


$ ./cli upload -h

cli upload - Upload a file

Alias: u

Usage:
  cli upload SOURCE [OPTIONS]
  cli upload --help | -h

Options:
  --force, -f
    Overwrite existing files

  --help, -h
    Show this help

Arguments:
  SOURCE
    File to upload