Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if defined(argument) being used for optional scalar arguments #2

Open
multimeric opened this issue Mar 12, 2020 · 2 comments · May be fixed by #4
Open

if defined(argument) being used for optional scalar arguments #2

multimeric opened this issue Mar 12, 2020 · 2 comments · May be fixed by #4

Comments

@multimeric
Copy link

For example, say I wanted to generate a WDL wrapper for the --lines flag for the unix tool head:

from wdlgen import Task

inp = Task.Command.CommandInput(
    name='lines',
    prefix='--lines',
    optional=True
)

print(inp.get_string())

This generates:

~{if defined(lines) then ("--lines " +  '"' + lines + '"') else ""}

However, what I want, based on this part of the spec is the much neater:

${"--lines=" + lines}

Or, including quotes:

${'--lines="' + lines + '"'}

How can I do this?

@illusional
Copy link
Member

The optional scalar values should definitely simplify to:

${"--lines=" + lines}

I didn't realise string + null + string => null and hence totally empty, hence:

~{if defined(lines) then ("--lines " +  '"' + lines + '"') else ""}

And should be simplified as you suggested to:

${'--lines="' + lines + '"'}

I'll issue a PR for this soon.

@illusional
Copy link
Member

(Future readers) Please see #4 (comment) for continuation of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants