Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
jflow
Commits
f66cbf59
Commit
f66cbf59
authored
Mar 02, 2013
by
Jerome Mariette
Browse files
handle bool type from command line
parent
f2be7d7a
Changes
3
Hide whitespace changes
Inline
Side-by-side
bin/jflow_cli.py
View file @
f66cbf59
...
...
@@ -115,10 +115,7 @@ if __name__ == '__main__':
# create the subparser for each applications
sub_parser
=
subparsers
.
add_parser
(
instance
.
name
,
help
=
instance
.
description
)
for
param
in
instance
.
parameters
:
sub_parser
.
add_argument
(
param
.
flag
,
type
=
param
.
type
,
help
=
param
.
help
,
required
=
param
.
required
,
dest
=
param
.
name
,
metavar
=
param
.
metavar
,
default
=
param
.
default
,
action
=
param
.
action
,
choices
=
param
.
choices
)
sub_parser
.
add_argument
(
param
.
flag
,
**
param
.
export_to_argparse
())
sub_parser
.
set_defaults
(
cmd_object
=
instance
.
__class__
.
__name__
)
args
=
vars
(
parser
.
parse_args
())
...
...
src/jflow/parameter.py
View file @
f66cbf59
...
...
@@ -52,9 +52,24 @@ class Parameter(object):
self
.
default
=
today
.
strftime
(
'%d/%m/%Y'
)
self
.
action
=
action
if
self
.
action
==
"append"
:
if
self
.
type
==
types
.
BooleanType
and
str
(
self
.
default
).
lower
()
in
(
"false"
,
"f"
,
"0"
):
self
.
action
=
"store_false"
self
.
default
=
True
elif
self
.
type
==
types
.
BooleanType
:
self
.
action
=
"store_true"
self
.
default
=
False
elif
self
.
action
==
"append"
:
self
.
default
=
[]
def
export_to_argparse
(
self
):
if
self
.
type
==
types
.
BooleanType
:
return
{
"help"
:
self
.
help
,
"required"
:
self
.
required
,
"dest"
:
self
.
name
,
"default"
:
self
.
default
,
"action"
:
self
.
action
}
else
:
return
{
"type"
:
self
.
type
,
"help"
:
self
.
help
,
"required"
:
self
.
required
,
"dest"
:
self
.
name
,
"metavar"
:
self
.
metavar
,
"default"
:
self
.
default
,
"action"
:
self
.
action
,
"choices"
:
self
.
choices
}
def
get_type
(
self
):
return
self
.
type
.
__name__
...
...
src/jflow/workflow.py
View file @
f66cbf59
...
...
@@ -206,6 +206,9 @@ class Workflow(threading.Thread):
extended_args
[
param
.
name
]
=
date
(
args
[
param
.
name
])
else
:
extended_args
[
param
.
name
]
=
args
[
param
.
name
]
# if it's a boolean
elif
param
.
type
==
types
.
BooleanType
:
extended_args
[
param
.
name
]
=
args
[
param
.
name
]
in
[
'true'
,
'1'
,
't'
,
'y'
,
'yes'
]
else
:
extended_args
[
param
.
name
]
=
args
[
param
.
name
]
# otherwise use the default
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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