diff --git a/docs/index.md b/docs/index.md index 00fa4fa..8516306 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 diff --git a/griddler/__main__.py b/griddler/__main__.py index 6c0b25d..eb7a699 100644 --- a/griddler/__main__.py +++ b/griddler/__main__.py @@ -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.", ) @@ -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": diff --git a/pyproject.toml b/pyproject.toml index 6934fc7..86c48d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,3 +23,6 @@ dev = [ [build-system] requires = ["hatchling"] build-backend = "hatchling.build" + +[project.scripts] +griddler = "griddler.__main__:main"