Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PaNOSC
Data Analysis Services
packme
Commits
06d7bb9e
Commit
06d7bb9e
authored
Jan 22, 2020
by
Eric Pellegrini
Browse files
added --version CLI option
parent
349895d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/packme
View file @
06d7bb9e
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment