What features does Bashly generate for a bash command line tool?

Updated

Bashly generates a single, standalone bash script that handles command-line parsing, validation, help output, and standard flags, while leaving your command-specific logic in separate files that it merges into the final script. This applies when you describe your CLI in a YAML configuration and run bashly generate; Bashly then produces the script and keeps your per-command code in its own files.

Command-line parsing and validation

Bashly parses the user's command line and extracts:

  • Positional arguments — optional or required.
  • Option flags — optional or required, with or without flag arguments.
  • Commands and subcommands — including nested subcommands.
  • Standard flags — such as --help and --version.

It also prevents your script from running unless the command line is valid, so invalid input is rejected before your code executes.

Help, usage, and documentation

Bashly generates usage texts and help screens that show your tool's arguments, flags, and commands, and this works for subcommands as well. It can additionally auto-generate markdown and man page documentation for your script.

Script quality

The generated script is:

  • Standalone — a single bash script.
  • Human readable.
  • shellcheck-compliant.
  • shfmt-compliant.

Where your code lives

Bashly provides a place to input your code for each function your tool performs and merges it back into the final script. Each command's code is kept in a separate file, and it can be merged again if you change it.

Optional framework-style helpers

Bashly also offers optional standard library functions, including:

  • Color output.
  • Config file management (INI format).
  • YAML parsing.
  • Bash completions.
  • And more.

How the pieces fit together

Stage What you do What Bashly does
Setup Run bashly init Creates an initial sample YAML file
Define Describe commands, subcommands, arguments, and flags in YAML —
Generate Run bashly generate Produces the standalone bash script with parsing, validation, and help
Implement Write code for each command in its separate file Merges your code into the final script

The practical effect is that you focus on your specific code rather than on argument parsing, usage texts, error messages, and similar concerns that a framework would normally handle in another language.