Commit 06d7bb9e authored by Eric Pellegrini's avatar Eric Pellegrini

added --version CLI option

parent 349895d4
......@@ -14,7 +14,7 @@ import sys
from typing import List
from packme import Packman
from packme import Packman, __version__
class NotSudo(Exception):
pass
......@@ -47,6 +47,11 @@ def clean_templates_dir(templates_base_dir: str):
except PermissionError:
raise NotSudo("Only sudoers can remove packer_cache directory")
def show_version():
print(__version__)
def parse_args() -> argparse.Namespace:
"""Returns the argument namespace after command-line parsing.
"""
......@@ -55,6 +60,7 @@ def parse_args() -> argparse.Namespace:
parser.add_argument("--log", "-l", dest="log", action="store_true", help="log packer output")
parser.add_argument("--key-rate", "-k", dest="key_rate", default="10", help="rate for automatic key entering (in ms)")
parser.add_argument("--clean", "-c", dest="clean", action="store_true", help="clean up templates directories")
parser.add_argument("--version", "-v", dest="version", action="store_true", help="show package version")
parser.add_argument("--debug", "-d", dest="debug", action="store_true", help="debug mode (keep temporary files)")
parser.add_argument("--run", "-r", dest="run", action="store_true", help="run packer after json manifest(s) generation")
parser.add_argument("--templates-base-dir", "-t", dest="templates_base_dir", required=True, help="Templates base directory")
......@@ -75,10 +81,15 @@ if __name__ == "__main__":
packages_base_dir : str = args.packages_base_dir
selected_templates : List[str] = args.selected_templates
clean : bool = args.clean
version : bool = args.version
debug : bool= args.debug
log : bool = args.log
key_rate : int = int(args.key_rate)
if version:
show_version()
sys.exit(0)
# If --clean option is set, cleanup the templates dir (builds, packer_cache, manifest.json files and directories)
if clean:
clean_templates_dir(templates_base_dir)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment