mirror of
https://github.com/kennethreitz-archive/plac.git
synced 2026-06-05 15:40:17 +00:00
16 lines
355 B
Python
16 lines
355 B
Python
# example1.py
|
|
def main(dsn):
|
|
"Do something with the database"
|
|
print(dsn)
|
|
# ...
|
|
|
|
if __name__ == '__main__':
|
|
import sys
|
|
n = len(sys.argv[1:])
|
|
if n == 0:
|
|
sys.exit('usage: python %s dsn' % sys.argv[0])
|
|
elif n == 1:
|
|
main(sys.argv[1])
|
|
else:
|
|
sys.exit('Unrecognized arguments: %s' % ' '.join(sys.argv[2:]))
|