parseArger is a standalone Bash argument parsing framework. It is self-hosted: the parseArger script itself uses the framework to parse its own arguments.
The project uses scripts in bin/ for build tasks.
- Regenerate Parser:
bin/generate- CRITICAL: The argument parsing logic in
parseArgerand scripts inbin/is GENERATED. - DO NOT manually edit code between
# @parseArger-parsingand# @parseArger-parsing-end. - To change arguments:
- Edit the
# @parseArgerdeclarations at the top of the file. - Run
bin/generate.
- Edit the
- CRITICAL: The argument parsing logic in
- Documentation:
bin/document - Completion:
bin/completely(generates shell completions) - Full Build:
bin/generate && bin/document && bin/completely
Tests are located in tests/ and end with .test.sh. They use a vendored bashunit library.
Execute the test script directly from the project root:
./tests/005_parse.test.shExecute all scripts in the tests/ directory:
for t in tests/*.test.sh; do
echo "Running $t..."
"$t" || exit 1
done- Language: Bash
- Indentation: Tabs (Use tabs for indentation, not spaces).
- Line Endings: Unix (
\n).
- Variables:
snake_case(e.g.,my_variable,file_path).- Internal/Generated variables often start with
_(e.g.,_arg_target).
- Internal/Generated variables often start with
- Functions:
snake_case(e.g.,parse_commandline,print_help).
- Variables:
- Always use
localfor variables declared inside functions. - Always quote variable expansions to prevent word splitting (e.g.,
"$var"instead of$var).
- Always use
- Error Handling:
- Use the
diefunction to exit with an error. - Usage:
die "Error message" [exit_code](default exit code is 1).
- Use the
- Imports:
- Use
sourceto import libraries. - Resolve paths relative to the script location or
PARSEARGER_ROOT_DIR. - Example:
source "$SCRIPT_ROOT_DIR/utils"
- Use
parseArger: Main executable entry point.bin/: Subcommands (e.g.,bin/parse,bin/generate).- Each file here corresponds to a subcommand (e.g.,
parseArger parse).
- Each file here corresponds to a subcommand (e.g.,
lib/: Helper libraries (e.g.,bashunit).tests/: Test scripts (*.test.sh).utils/: Utility scripts included by subcommands.
- Check for Generated Code: Before editing a file, check for
# @parseArgerannotations. If they exist, ensure you are editing the declarations and regenerating, rather than editing the parsing logic directly. - Paths: Always use absolute paths in tool calls, but write code that uses relative paths or dynamic path resolution (like
$(dirname ...)).