Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
# griddler

Griddles are the main functionality of griddle. Read about the [griddle schema](griddles.md) to get started.
Griddles are the main functionality of griddle. Read about the [griddle schema](griddles.md) to learn more about the format.

## Using griddler from the command line
## Getting started

Griddler can also be used on the command line to read an input YAML (or JSON) and write output JSON:
### Command-line usage

Griddler can be used from the command line with any language. It reads a YAML (or JSON)
griddle definition and writes the expanded parameter sets as JSON.

You can install it from GitHub with `uv` or another git-backed package maanger:

```bash
uv tool install git+https://github.com/cdcgov/pygriddler.git
```
python -m griddler my_griddle.yaml > my_parameter_sets.json

Example usage:

```bash
griddler my_griddle.yaml > my_parameter_sets.json
```

Use the `--help` flag for more details.

## Using griddle in other python projects
### Python API

You can also directly generate a griddle directly in Python:

You can generate a griddle directly in Python:
```bash
uv add git+https://github.com/cdcgov/pygriddler.git
```

```python
import yaml
Expand Down
9 changes: 7 additions & 2 deletions griddler/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import griddler


def main(args):
def main(args=None):
parser = argparse.ArgumentParser(
prog="python -m griddler",
prog="griddler",
description="Parse a griddle into a list of dictionaries.",
)

Expand Down Expand Up @@ -52,6 +52,11 @@ def main(args):

args = parser.parse_args(args)

# Show help if no args are provided
if args.input is sys.stdin and sys.stdin.isatty():
parser.print_help()
sys.exit(1)

if args.from_ == "yaml":
raw = yaml.safe_load(args.input)
elif args.from_ == "json":
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ dev = [
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project.scripts]
griddler = "griddler.__main__:main"
Loading