✨ Add command line argument support and remove unused dependencies
This commit is contained in:
1
projects/hello-world/.python-version
Normal file
1
projects/hello-world/.python-version
Normal file
@@ -0,0 +1 @@
|
||||
3.12
|
||||
@@ -1,2 +1,22 @@
|
||||
import argparse
|
||||
|
||||
|
||||
def parse_args():
|
||||
ap = argparse.ArgumentParser()
|
||||
|
||||
ap.add_argument(
|
||||
"-n", "--name",
|
||||
required=False,
|
||||
help="The name",
|
||||
)
|
||||
|
||||
return ap, ap.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
print("Hello World!")
|
||||
ap, args = parse_args()
|
||||
print(f"Hello {args.name if args.name else "World"}!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
[project]
|
||||
name = "hello-world"
|
||||
version = "0.1.0"
|
||||
dependencies = ["requests"]
|
||||
|
||||
[project.scripts]
|
||||
run = "main:main"
|
||||
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = []
|
||||
|
||||
Reference in New Issue
Block a user