Рефакторинг обработки аргументов

This commit is contained in:
Andrei Astafev 2019-07-04 11:50:42 +03:00
parent 016d4f120f
commit 6804614d04
2 changed files with 16 additions and 13 deletions

View File

@ -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)

View File

@ -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