argparse
This commit is contained in:
26
argparse/action.py
Executable file
26
argparse/action.py
Executable file
@@ -0,0 +1,26 @@
|
||||
#! /usr/bin/python3
|
||||
|
||||
import argparse
|
||||
|
||||
def do_test():
|
||||
print('do_test()')
|
||||
|
||||
parser = argparse.ArgumentParser(prog='action',description='Demonstration der Action',epilog='Ende der Hilfe')
|
||||
|
||||
parser.add_argument('--update',help='update Hilfe')
|
||||
parser.add_argument('--dry-run',help='dry-run Hilfe')
|
||||
parser.add_argument('--verbose','-v', action='count')
|
||||
parser.add_argument('--true', action='store_true')
|
||||
parser.add_argument('-append', action='append', nargs=1)
|
||||
parser.add_argument('--false', action='store_false')
|
||||
parser.add_argument('--store', action='store')
|
||||
parser.add_argument('--const', action = 'store_const', const=19)
|
||||
|
||||
parser.add_argument('--delete', action = argparse.BooleanOptionalAction)
|
||||
#parser.add_argument('--no-delete', action = argparse.BooleanOptionalAction)
|
||||
|
||||
|
||||
args=parser.parse_args()
|
||||
print(f'args={args}')
|
||||
print(f'verbose={args.verbose}')
|
||||
|
11
argparse/help.py
Executable file
11
argparse/help.py
Executable file
@@ -0,0 +1,11 @@
|
||||
#! /usr/bin/python3
|
||||
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(prog='HILFE',description='Demonstration der Hilfeseite',epilog='Ende der Hilfe im Epilog')
|
||||
|
||||
parser.add_argument('--update',help='update Hilfe')
|
||||
parser.add_argument('--dry-run',help='dry-run Hilfe')
|
||||
|
||||
args=parser.parse_args()
|
||||
|
Reference in New Issue
Block a user