Skip to content

Commit 002a776

Browse files
committed
Bundle: Improve handling of --format option
1 parent 8e01ced commit 002a776

5 files changed

Lines changed: 30 additions & 8 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Outline: Significantly update `cratedb-outline.yaml`
1717
- Bundle: Started accepting `--url`/`ABOUT_OUTLINE_URL` option to specify
1818
alternative input outline file
19+
- Bundle: Improved handling of `--format` option
1920

2021
## v0.0.3 - 2025-05-10
2122
- Outline: Refactored the source of truth for the documentation outline

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ The Markdown file `outline.md` serves as the source for producing the
153153
`llms.txt` files. Generate multiple `llms.txt` files along with any
154154
auxiliary output files.
155155
```shell
156-
cratedb-about bundle --format=llms-txt --outdir=./public_html
156+
cratedb-about bundle --format=llm --outdir=./public_html
157157
```
158158
By default, the bundler will use the built-in `cratedb-outline.yaml` as input file.
159159
You can select an alternative input file using the `--url` option, or the

src/cratedb_about/bundle/llmstxt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LllmsTxtBuilder:
2020
outdir: Path
2121

2222
def run(self):
23-
logger.info(f"Bundling llms-txt. Output directory: {self.outdir}")
23+
logger.info(f"Creating bundle. Format: llms-txt. Output directory: {self.outdir}")
2424
self.outdir.mkdir(parents=True, exist_ok=True)
2525

2626
logger.info("Copying source and documentation files")

src/cratedb_about/cli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,20 @@ def outline(
7272
@cli.command()
7373
@outline_url_option
7474
@click.option(
75-
"--format", "-f", "format_", type=str, default="llms-txt", help="Output format: Use llms-txt"
75+
"--format",
76+
"-f",
77+
"format_",
78+
type=click.Choice(["llm"]),
79+
required=True,
80+
help="Bundle output format",
7681
)
7782
@click.option("--outdir", "-o", envvar="OUTDIR", type=Path, required=True)
7883
@click.pass_context
7984
def bundle(ctx: click.Context, url: str, format_: str, outdir: Path) -> None:
8085
"""
8186
Invoke the bundling. For now: Generate multiple `llms.txt` files.
8287
"""
83-
if format_ != "llms-txt":
88+
if format_ != "llm":
8489
raise click.BadOptionUsage("format", f"Invalid output format: {format_}", ctx=ctx)
8590
builder = LllmsTxtBuilder(outline_url=url, outdir=outdir)
8691
builder.run()

tests/test_cli.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ def test_cli_bundle_success(caplog, tmp_path):
5151
# Invoke command.
5252
result = runner.invoke(
5353
cli,
54-
args=["bundle"],
54+
args=["bundle", "--format", "llm"],
5555
env={"ABOUT_OUTLINE_URL": TESTING_OUTLINE_FILE, "OUTDIR": str(tmp_path)},
5656
catch_exceptions=False,
5757
)
5858
assert result.exit_code == 0, result.output
5959

6060
# Verify log output.
61-
assert "Bundling llms-txt" in caplog.text
61+
assert "Creating bundle. Format: llms-txt" in caplog.text
6262
assert "Ready." in caplog.text
6363

6464
# Verify that the expected output files have been created.
@@ -72,7 +72,7 @@ def test_cli_bundle_without_outdir():
7272
# Invoke command without OUTDIR environment variable.
7373
result = runner.invoke(
7474
cli,
75-
args=["bundle"],
75+
args=["bundle", "--format", "llm"],
7676
env={}, # No OUTDIR set
7777
catch_exceptions=False,
7878
)
@@ -82,6 +82,22 @@ def test_cli_bundle_without_outdir():
8282
assert "Error: Missing option '--outdir' / '-o'" in result.output
8383

8484

85+
def test_cli_bundle_without_format(tmp_path):
86+
runner = CliRunner()
87+
88+
# Invoke command.
89+
result = runner.invoke(
90+
cli,
91+
args=["bundle"],
92+
env={"OUTDIR": str(tmp_path)},
93+
catch_exceptions=False,
94+
)
95+
96+
# Verify appropriate error handling.
97+
assert result.exit_code != 0, result.output
98+
assert "Error: Missing option '--format' / '-f'" in result.output
99+
100+
85101
def test_cli_bundle_invalid_format(tmp_path):
86102
runner = CliRunner()
87103

@@ -95,4 +111,4 @@ def test_cli_bundle_invalid_format(tmp_path):
95111

96112
# Verify appropriate error handling.
97113
assert result.exit_code != 0, result.output
98-
assert "Error: Invalid output format: foobar" in result.output
114+
assert "Error: Invalid value for '--format' / '-f': 'foobar' is not 'llm'" in result.output

0 commit comments

Comments
 (0)