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

Option for put no space between parameter and value #288

Closed
IncredibleRichie opened this issue Apr 3, 2020 · 16 comments
Closed

Option for put no space between parameter and value #288

IncredibleRichie opened this issue Apr 3, 2020 · 16 comments

Comments

@IncredibleRichie
Copy link

To execute packer with the parameter
-var-file=

you need to put the path directly behind
'='
with no space.

When i select a server-file it puts a whithespace between the parameter and the path.

At the moment i think this is not posible to change the behavior.
If it is can u tell me how?

btw. Thanks for your great work.

@bugy
Copy link
Owner

bugy commented Apr 3, 2020

Hey, unfortunately, it's not supported :(
For some reason, nobody ever asked about it (at least I couldn't find a ticket)

@bugy bugy added the feature label Apr 3, 2020
@IncredibleRichie
Copy link
Author

I looked for it too becauce i could not belive it. ^^

@bugy
Copy link
Owner

bugy commented Jun 10, 2020

From #308
@miksir wrote:

Hi! I got a request for support --arg=value. Currently there is no options to do it because space added between argument name and value. I can see two ways - separate options for it (do_not_add_space \o/) or transparent behaviour - if arg name ended with = - do not include space. What you think about second way?

Hi @miksir I think the second one is cooler, though a bit dangerous. I think we can try it and see if there are any complaints :)

@miksir
Copy link

miksir commented Jun 10, 2020

ok, will make PR today

@yosefy
Copy link

yosefy commented Jun 10, 2020 via email

@bugy
Copy link
Owner

bugy commented Jun 10, 2020

Hi @yosefy, how do you do it now? With a wrapping script?

@miksir
Copy link

miksir commented Jun 10, 2020

Is quotes required here? Usually quotes used only if value with spaces and only because shell use space as arg delimiter. But in case of popen args passed to system as separate items and quotes not required. Am I right?

@miksir
Copy link

miksir commented Jun 10, 2020

How mutiple arguments list shoud work?
--arg=a b c
--arg=a,b,c
--arg=a --arg=b --arg=c

@bugy
Copy link
Owner

bugy commented Jun 10, 2020

@miksir I think in the same way as normal behavior. By using separator and multiple_arguments configs, you can achieve the last 2 results.
The first one doesn't make much sense to me (to have the last 2 arguments as separate arguments). I've never seen such behaviour before

@miksir
Copy link

miksir commented Jun 10, 2020

Last one you can't achieve. multiple_arguments with separator= --arg= will give you --arg=a --arg=b --arg=c - one argument (it's like --arg="a --arg=b --arg=c" in command line).

Same trouble with current behavior.

    {
      "name": "Name",
      "param": "-d",
      "type": "multiselect",
      "values": [
        "a",
        "b",
        "c"
      ],
      "multiple_arguments": true
    }

Gives

0=temp/test.sh
1=-d
2=a
3=b
4=c

but

    {
      "name": "Name",
      "param": "-d",
      "type": "multiselect",
      "values": [
        "a",
        "b",
        "c"
      ],
      "multiple_arguments": false,
      "separator": " -d "
    }

gives

0=temp/test.sh
1=-d
2=a -d b -d c
3=
4=

so there is no way to make 1=-d 2=a 3=-d 4=b as if we called it from command line

@miksir
Copy link

miksir commented Jun 10, 2020

My suggestion is to change current behaviour too, but its breaks BC :(
Or add option "add Arg to each value".
Or leave current behaviour untouched but for -arg= change this behaviour and implement --arg=a --arg=b --arg=c

@yosefy
Copy link

yosefy commented Jun 10, 2020 via email

@bugy
Copy link
Owner

bugy commented Jun 10, 2020

Ah, true, that case is missing.
But I wouldn't change current behaviour, as it makes sense, to be honest. Some scripts could expect -b 1 2 3 and other would expect -b 1 -b 2 -b 3

I think both of your 2nd and 3rd proposals make sense. There can be such option (may be, I would call it repeat_param), which would be enabled by default for the -arg= parameters.

@miksir
Copy link

miksir commented Jun 10, 2020

Never saw -b 1 2 3 variants... -b "1 2 3" - yes, but separate args? Usually it's -b <b arg> <new arg> <new arg> - so just additional args.

@bugy
Copy link
Owner

bugy commented Jun 10, 2020

https://stackoverflow.com/questions/15753701/how-can-i-pass-a-list-as-a-command-line-argument-with-argparse here different answers suggest different syntax styles, with all 3 variants here.
(It was the first SO result for google request: "python argparse list")

So I would assume all 3 variants exist in a wild

@miksir
Copy link

miksir commented Jun 10, 2020

PR #310

bugy added a commit that referenced this issue Jun 11, 2020
#288 Remove space between arg name and value, support of arg repeating with each value
@bugy bugy added the resolved label Aug 9, 2020
@bugy bugy added this to the 1.16.0 milestone Aug 9, 2020
@bugy bugy closed this as completed Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants