Merge pull request 'templates: add python-project' (#10) from python-template into main
This commit is contained in:
17
templates/python-project/my_tool/__init__.py
Normal file
17
templates/python-project/my_tool/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import argparse
|
||||
|
||||
# statement that doesn't need testing
|
||||
__version__ = "1.0.0" # pragma: no cover
|
||||
|
||||
|
||||
# this will be an entrypoint under /bin/my_cli (see pyproject.toml config)
|
||||
def my_cli() -> None:
|
||||
parser = argparse.ArgumentParser(description="my-tool")
|
||||
parser.add_argument(
|
||||
"-v", "--version", help="Show the version of this program", action="store_true"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
if args.version:
|
||||
print(f"Version: {__version__}")
|
||||
else:
|
||||
parser.print_help()
|
||||
Reference in New Issue
Block a user