python-template
ReferenceCommands

hello

Print a greeting

The example command the template ships. Delete it once you have a real one — it exists to show the shape, not to be useful.

What it does

Prints a greeting to stdout. The implementation lives in src/pythontemplate/commands/hello.py and returns its string rather than printing it; cli.py does the printing. That split is deliberate — it keeps the behaviour testable without capturing stdout.

Output

One line on stdout:

$ python-template hello
Hello, world!

Flags

FlagTypeDefaultEffect
NAME / --namestringworldWho to greet. Must contain at least one non-space character.
--shout / --no-shoutboolFalseUppercase the whole greeting.

NAME is positional-or-named: hello Robin and hello --name Robin are equivalent.

Exit codes

CodeMeaning
0Greeting printed.
1NAME was empty or whitespace only. The message goes to stderr as python-template: name must not be empty, with no traceback.

The clean exit-1 path is main() catching ValueError in src/pythontemplate/cli.py. Raise ValueError from a command to get the same treatment.

Examples

$ python-template hello
Hello, world!

$ python-template hello Robin
Hello, Robin!

$ python-template hello Robin --shout
HELLO, ROBIN!

$ python-template hello "   "
python-template: name must not be empty
$ echo $?
1

On this page