command_line_utils
Module for command line utils
read_command_line_arguments()
Reads the command line arguments given to the tool
Returns:
Type | Description |
---|---|
Path |
input yaml path |
Source code in utils/command_line_utils.py
def read_command_line_arguments():
"""Reads the command line arguments given to the tool
Returns:
Path: input yaml path
"""
# Initialize parser with the multiline description
parser = argparse.ArgumentParser(
description=PROGRAM_DESCRIPTION,
formatter_class=argparse.RawTextHelpFormatter,
)
# Adding optional argument
parser.add_argument(
"input_file",
nargs="?",
help="Input yaml file",
)
parser.add_argument("-v", "--version", action="store_true", help="Show version")
# Read arguments from command line
args = parser.parse_args()
if args.input_file:
input_path = Path(args.input_file)
elif args.version:
version = read_version_number()
print("D-EcoImpact version:", version)
sys.exit()
else:
print("\nNo inputfile given.\n")
print("===========================================")
parser.print_help()
print("===========================================")
input("\nPlease provide an input.yaml file. Hit Enter to exit.\n")
sys.exit()
return input_path