Work with the attune-rag CLI
Use the attune_rag.cli module when you need to run retrieval queries or inspect corpus statistics from the command line.
Prerequisites
- Access to the project source code at
src/attune_rag/cli.py - A working Python environment with
attune_raginstalled
Steps
-
Review the two public entry points. Open
src/attune_rag/cli.pyand locatebuild_parser()andmain().build_parser()constructs the argument parser that defines all available subcommands and flags.main()is the entry point that parsesargvand dispatches to the appropriate handler. -
Identify which function owns the behavior you need.
- To add or modify a subcommand, flag, or argument, work in
build_parser(). - To change how the CLI dispatches, handles errors, or returns exit codes, work in
main().
- To add or modify a subcommand, flag, or argument, work in
-
Edit the target function. Make your changes in
src/attune_rag/cli.py. Keep argument names consistent with those already defined inbuild_parser(), and ensuremain()returns an integer exit code. -
Run the related tests. Execute
pytest -k "cli"to catch regressions before they affect other developers. -
Verify the CLI behaves as expected. Call
main()directly with a list of arguments, or invoke the installed command from your shell. Confirm the output, exit code, and any error messages match your intent.
Verify success
You know this task is complete when:
pytest -k "cli"passes with no failures- Calling
main()with valid arguments returns0 - Calling
main()with invalid arguments returns a non-zero exit code and prints a usage message
Key files
src/attune_rag/cli.py— containsbuild_parser()andmain()