Skip to content

Commit 1aff43f

Browse files
committed
style: remove bake action
This is technically a breaking change but only for invoking.
1 parent 3a921eb commit 1aff43f

5 files changed

Lines changed: 23 additions & 35 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pipx ensurepath
6262
4. Generate PDFs with:
6363

6464
```bash
65-
pdfbaker bake <config_file>
65+
pdfbaker <config_file>
6666
```
6767

6868
This will produce your PDF files in a `dist/` directory where your configuration file
@@ -82,7 +82,7 @@ For working examples, see the [examples](examples) directory:
8282
Create all PDFs with:
8383

8484
```bash
85-
pdfbaker bake examples/examples.yaml
85+
pdfbaker examples/examples.yaml
8686
```
8787

8888
## Documentation

docs/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ At least `documents` has to be specified.
3232
| `documents` **required** | array | `[]` | List of document configurations. A simple string specifies the name of a directory under `directories.documents`. A directory needs to contain a `config.yaml` file. You can also specify `path` and `name` to a specific directory or configuration YAML file. |
3333
| `directories` | mapping | see the following settings | You can override default directories with the `directories` mapping, just re-define one or more with one of the following settings. |
3434
| `directories.base` **readonly** | string | directory containing the config file | If directories are not absolute paths they will be relative to this base directory. |
35-
| `directories.build` | string | `"build"` | Intermediary SVG and PDF files are written here. Deleted unless `bake` is run with `--keep-build` |
35+
| `directories.build` | string | `"build"` | Intermediary SVG and PDF files are written here. Deleted unless you specified `--keep-build`. |
3636
| `directories.dist` | string | `"dist"` | Final PDF files are written here. |
3737
| `directories.documents` | string | `"."` | Location of document configurations. |
3838
| `directories.images` | string | `"images"` | Location of image files. |
@@ -43,7 +43,7 @@ At least `documents` has to be specified.
4343
| `template_filters` | array | `["wordwrap"]` | List of filters made available to templates. `wordwrap` is currently the only available filter. It splits text into lines so that full words have to fit within the specified total number of character for example `{% set desc_lines = item.desc \| wordwrap(40) %}`. |
4444
| `svg2pdf_backend` | string | `"cairosvg"` | Backend to use for SVG to PDF conversion. `"cairosvg"` is built-in, the alternative `"inkscape"` requires Inkscape to be installed |
4545
| `compress_pdf` | boolean | `false` | Whether to compress the final PDF. Requires Ghostscript to be installed. |
46-
| `keep_build` | boolean | `false` | Whether to keep the `build` directory and its intermediary files. You can also pass `bake --keep-build` on individual calls to do this. |
46+
| `keep_build` | boolean | `false` | Whether to keep the `build` directory and its intermediary files. You can also pass `--keep-build` on individual calls to do this. |
4747
| _additional custom setting_ | | | Any settings you want to make available to all pages of all documents. |
4848

4949
<details>

docs/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ like LaTex, even if your end result is exported to PDF.
4242
1. Create your document in an SVG editor or convert to SVG
4343
2. Replace text with variables, add conditions and loops using Jinja2
4444
3. Configure your content and settings in YAML
45-
4. Generate PDFs with `pdfbaker bake`
45+
4. Generate PDFs with `pdfbaker yourconfig.yaml`
4646

4747
### From configuration to PDF documents
4848

src/pdfbaker/__main__.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
logger = logging.getLogger(__name__)
1414

1515

16-
@click.group()
16+
@click.command()
1717
@click.version_option(version=__version__, prog_name="pdfbaker")
18-
def cli() -> None:
19-
"""Generate PDF documents from YAML-configured SVG templates."""
20-
21-
22-
@cli.command()
2318
@click.argument(
2419
"config_file",
2520
type=click.Path(exists=True, dir_okay=False, path_type=Path),
@@ -36,16 +31,16 @@ def cli() -> None:
3631
@click.option("--keep-build", is_flag=True, help="Keep build artifacts")
3732
@click.option("--debug", is_flag=True, help="Debug mode (--verbose and --keep-build)")
3833
# pylint: disable=too-many-arguments,too-many-positional-arguments
39-
def bake(
34+
def cli(
4035
config_file: Path,
4136
documents: tuple[str, ...],
4237
quiet: bool,
4338
verbose: bool,
4439
trace: bool,
4540
keep_build: bool,
4641
debug: bool,
47-
) -> int:
48-
"""Parse config file and bake PDFs.
42+
) -> None:
43+
"""Generate PDF documents from YAML-configured SVG templates.
4944
5045
Optionally specify one or more document names to only process those documents.
5146
"""
@@ -72,4 +67,4 @@ def bake(
7267

7368

7469
if __name__ == "__main__":
75-
cli()
70+
cli() # pylint: disable=no-value-for-parameter

tests/test_cli.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,41 @@ def test_cli_version():
1818

1919

2020
def test_cli_help():
21-
"""CLI: --help outputs usage and commands."""
21+
"""CLI: --help outputs usage and options."""
2222
runner = CliRunner()
2323
result = runner.invoke(cli, ["--help"])
2424
assert result.exit_code == 0
2525
assert "Usage:" in result.output
26-
assert "bake" in result.output
27-
assert "version" in result.output
28-
29-
30-
def test_cli_bake_help():
31-
"""CLI: bake --help outputs bake options."""
32-
runner = CliRunner()
33-
result = runner.invoke(cli, ["bake", "--help"])
34-
assert result.exit_code == 0
35-
assert "Usage:" in result.output
26+
assert "CONFIG_FILE" in result.output
3627
assert "--quiet" in result.output
3728
assert "--verbose" in result.output
29+
assert "--trace" in result.output
30+
assert "version" in result.output
3831
assert "--keep-build" in result.output
3932

4033

4134
def test_cli_bake_missing_config(tmp_path: Path):
42-
"""CLI: bake with missing config file reports error."""
35+
"""CLI: with missing config file reports error."""
4336
runner = CliRunner()
44-
result = runner.invoke(cli, ["bake", str(tmp_path / "missing.yaml")])
37+
result = runner.invoke(cli, [str(tmp_path / "missing.yaml")])
4538
assert result.exit_code == 2
4639
assert "does not exist" in result.output
4740

4841

4942
def test_cli_bake_invalid_config(tmp_path: Path):
50-
"""CLI: bake with invalid config file reports YAML and validation errors."""
43+
"""CLI: with invalid config file reports YAML and validation errors."""
5144
config_file = tmp_path / "invalid.yaml"
5245
config_file.write_text("invalid: yaml: content")
5346
runner = CliRunner()
54-
result = runner.invoke(cli, ["bake", str(config_file)])
47+
result = runner.invoke(cli, [str(config_file)])
5548
assert result.exit_code == 1
5649
assert result.exception is not None
5750
assert "mapping values are not allowed here" in str(result.exception)
5851
config_file.write_text("""
5952
directories:
6053
base: /tmp
6154
""")
62-
result = runner.invoke(cli, ["bake", str(config_file)])
55+
result = runner.invoke(cli, [str(config_file)])
6356
assert result.exit_code == 1
6457
assert result.exception is not None
6558
exception_str = str(result.exception)
@@ -75,7 +68,7 @@ def test_cli_bake_invalid_config(tmp_path: Path):
7568
directories:
7669
base: /tmp
7770
""")
78-
result = runner.invoke(cli, ["bake", str(abs_config)])
71+
result = runner.invoke(cli, [str(abs_config)])
7972
assert result.exit_code == 0
8073

8174

@@ -87,15 +80,15 @@ def test_cli_bake_verbosity_flags(tmp_path: Path):
8780
failing_config = tmp_path / "failing.yaml"
8881
failing_config.write_text("pages: [page1.yaml]\ndirectories:\n build: build\n")
8982
runner = CliRunner()
90-
result = runner.invoke(cli, ["bake", "--quiet", str(failing_config)])
83+
result = runner.invoke(cli, ["--quiet", str(failing_config)])
9184
assert result.exit_code == 1
9285
assert result.output == ""
9386
success_config = tmp_path / "success.yaml"
9487
success_config.write_text("documents: []\ndirectories:\n base: /tmp\n")
95-
result = runner.invoke(cli, ["bake", "--quiet", str(success_config)])
88+
result = runner.invoke(cli, ["--quiet", str(success_config)])
9689
assert result.exit_code == 0
9790
assert result.output == ""
98-
result = runner.invoke(cli, ["bake", "--verbose", str(success_config)])
91+
result = runner.invoke(cli, ["--verbose", str(success_config)])
9992
assert result.exit_code == 0
10093
assert "DEBUG" in result.output
10194
assert "Loading main configuration" in result.output

0 commit comments

Comments
 (0)