36 lines
794 B
Python
36 lines
794 B
Python
#!/usr/bin/env python3
|
|
"""things.py - description here."""
|
|
|
|
import argparse
|
|
|
|
|
|
def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser(description="things.py - description here.")
|
|
parser.add_argument(
|
|
"input",
|
|
nargs="?",
|
|
help="input file or value to process",
|
|
)
|
|
parser.add_argument(
|
|
"-o",
|
|
"--output",
|
|
help="output file (defaults to stdout)",
|
|
)
|
|
parser.add_argument(
|
|
"-v",
|
|
"--verbose",
|
|
action="store_true",
|
|
help="enable verbose output",
|
|
)
|
|
return parser.parse_args(argv)
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
if args.verbose:
|
|
print(f"input={args.input!r} output={args.output!r}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|