Рефакторинг обработки аргументов
This commit is contained in:
parent
016d4f120f
commit
6804614d04
@ -1,9 +1,21 @@
|
||||
print("loading py3x/__init__.py")
|
||||
|
||||
import sys
|
||||
from py3x.functions import parse_args
|
||||
|
||||
def main():
|
||||
""" Main function """
|
||||
print("running function main from py3x/__init__.py")
|
||||
parse_args()
|
||||
|
||||
args = parse_args(sys.argv[1:])
|
||||
|
||||
if args.verbose:
|
||||
if args.input:
|
||||
print("input file name is: {}".format(args.input))
|
||||
if args.output:
|
||||
print("output file name is: {}".format(args.output))
|
||||
else:
|
||||
if args.input:
|
||||
print(args.input)
|
||||
if args.output:
|
||||
print(args.output)
|
||||
|
@ -2,7 +2,7 @@ print("loading py3x/functions.py")
|
||||
|
||||
import argparse
|
||||
|
||||
def parse_args():
|
||||
def parse_args(args):
|
||||
""" Parse command line arguments """
|
||||
print("running function parse_args from py3x/functions.py")
|
||||
|
||||
@ -13,15 +13,6 @@ def parse_args():
|
||||
help="Output file name")
|
||||
parser.add_argument("-v", "--verbose", action="store_true",
|
||||
help="Increase output verbosity")
|
||||
args = parser.parse_args()
|
||||
if args.verbose:
|
||||
if args.input:
|
||||
print("input file name is: {}".format(args.input))
|
||||
if args.output:
|
||||
print("output file name is: {}".format(args.output))
|
||||
else:
|
||||
if args.input:
|
||||
print(args.input)
|
||||
if args.output:
|
||||
print(args.output)
|
||||
args = parser.parse_args(args)
|
||||
return args
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user