How the Bashly Workflow Turns a YAML File into a Bash Script
Updated
Bashly is a command line application written in Ruby that generates feature-rich bash command line tools. The workflow is: you describe your tool's commands, subcommands, arguments, and flags in a YAML configuration file, then run bashly generate to produce a single standalone bash script that parses and validates user input, prints help messages, and runs your code for each command. This suits anyone who wants framework-style argument parsing and help screens without writing that logic by hand in bash.
Step 1: Create the initial YAML configuration
Run bashly init to create an initial sample YAML file. This gives you a working starting point that you then edit to match your own tool.
Step 2: Describe your tool in YAML
In the configuration file, define:
- Commands and subcommands — the structure of your tool.
- Positional arguments — optional or required.
- Option flags — optional or required, with or without flag arguments.
Bashly uses this description both to generate the parser and to generate usage texts and help screens, including for subcommands.
Step 3: Generate the script
Run bashly generate. Bashly produces a single, standalone bash script that:
- Parses the user's command line and extracts arguments, flags, commands, and standard flags like
--helpand--version. - Prevents your script from running unless the command line is valid.
- Includes human-readable output that is shellcheck-compliant and shfmt-compliant.
Step 4: Keep command code in separate files
Your code for each command lives in its own separate file. Bashly provides a place to input the code for each function your tool performs and merges it back into the final script. If you change the generated script, your separate files can be merged again.
What Bashly handles for you
| Responsibility | Handled by Bashly |
|---|---|
| Argument and flag parsing | Yes |
| Usage texts and help screens | Yes, including subcommands |
| Input validation before running | Yes |
| Single standalone script output | Yes |
| Optional standard library functions | Color output, INI config management, YAML parsing, bash completions, and more |
| Documentation | Auto-generated markdown and man pages |
When this workflow fits
Choose Bashly if you want to focus on your tool's specific code rather than on argument parsing, usage texts, and error messages. The trade-off is that you maintain a YAML description alongside your command files, and you regenerate the script after configuration changes rather than editing the final script directly.