| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + #!/usr/bin/env python3 | ||
| 2 | + """A single positional argument""" | ||
| 3 | + | ||
| 4 | + import argparse | ||
| 5 | + | ||
| 6 | + | ||
| 7 | + # -------------------------------------------------- | ||
| 8 | + def get_args(): | ||
| 9 | + """Get command-line arguments""" | ||
| 10 | + | ||
| 11 | + parser = argparse.ArgumentParser( | ||
| 12 | + description='A single positional argument', | ||
| 13 | + formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
| 14 | + | ||
| 15 | + parser.add_argument('name', metavar='name', help='The name to greet') | ||
| 16 | + | ||
| 17 | + return parser.parse_args() | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + # -------------------------------------------------- | ||
| 21 | + def main(): | ||
| 22 | + """Make a jazz noise here""" | ||
| 23 | + | ||
| 24 | + args = get_args() | ||
| 25 | + print('Hello, ' + args.name + '!') | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + # -------------------------------------------------- | ||
| 29 | + if __name__ == '__main__': | ||
| 30 | + main() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments