From 1e45c58ca22f8c0564fb79497da957650f89e6b0 Mon Sep 17 00:00:00 2001 From: Mira Okafor Date: Mon, 9 Mar 2026 20:31:00 -0500 Subject: [PATCH] cli: accept the name as a positional argument `hello-hut Ada` reads better than `hello-hut --name Ada`. --- README.md | 4 +++- src/hello_hut/cli.py | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b65dd952f84e8d5364dc014b80a5059f8173a51e..563463e26dd004cda10b13e5a64077b68bccb7f6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ hello — and that is all it does. ## Usage ```console -$ hello-hut --name Ada +$ hello-hut +Hello, friend! +$ hello-hut Ada Hello, Ada! ``` diff --git a/src/hello_hut/cli.py b/src/hello_hut/cli.py index 69398d0dd94f4cacf1a6985ecd337688d65a30a9..9110eb394310a53122d8e131c3e593abd80647a3 100644 --- a/src/hello_hut/cli.py +++ b/src/hello_hut/cli.py @@ -12,8 +12,7 @@ def build_parser(): prog="hello-hut", description="A friendly greeting tool for your terminal.", ) - parser.add_argument("--name", default=DEFAULT_NAME, - help="who to greet (default: %(default)s)") + parser.add_argument("name", nargs="?", help="who to greet") parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}") return parser @@ -21,7 +20,7 @@ def build_parser(): def main(argv=None): args = build_parser().parse_args(argv) - name = args.name + name = args.name or DEFAULT_NAME message = greet(name) print(message)