Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
synergy
o3skim
Commits
496c80e1
Commit
496c80e1
authored
Aug 12, 2020
by
BorjaEst
Browse files
Added argparse to main
parent
a4f11ed2
Changes
2
Hide whitespace changes
Inline
Side-by-side
cicd/module_template.py
View file @
496c80e1
...
...
@@ -4,6 +4,6 @@
def
hello_world
(
*
arg
,
**
kvarg
):
print
(
"Hello World"
)
if
arg
or
kvarg
:
print
(
f
" - Arguments as
i
nputs:
{
arg
}
"
)
print
(
f
" -
Key-Value arguments
:
{
kvarg
}
"
)
print
(
f
" - Arguments as
I
nputs:
{
arg
}
"
)
print
(
f
" -
Arguments as KeyVal
:
{
kvarg
}
"
)
return
True
main
100644 → 100755
View file @
496c80e1
#!/usr/bin/env python3
"""
Main function description - To show in command help
"""
import
sys
import
argparse
from
cicd
import
module_template
module_template
.
hello_world
()
def
cmdline_args
():
p
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
)
p
.
add_argument
(
"non_required_int"
,
nargs
=
'?'
,
type
=
int
,
help
=
"non_required_int description"
)
p
.
add_argument
(
"-v"
,
"--verbosity"
,
type
=
int
,
choices
=
[
0
,
1
,
2
],
default
=
0
,
help
=
"increase output verbosity (default: %(default)s)"
)
group1
=
p
.
add_mutually_exclusive_group
(
required
=
False
)
group1
.
add_argument
(
'--enable'
,
action
=
"store_true"
)
group1
.
add_argument
(
'--disable'
,
action
=
"store_false"
)
return
(
p
.
parse_args
())
if
__name__
==
'__main__'
:
args
=
cmdline_args
()
module_template
.
hello_world
(
args
,
**
vars
(
args
))
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