-
-
Notifications
You must be signed in to change notification settings - Fork 261
How to execute script only if a single parameter is given #246
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hi @Nottt unfortunately, that's not possible. If parameter is not specified, it's not passed at all |
So what I should do to accomplish what I want? I don't want to clutter the UI with lots of scripts |
So what I should do to accomplish what I want? I don't want to clutter the UI with lots of scripts. I'm not sure you understood me...what I saying is that I want to control inside the script what variable is what... Either by controlling the order (e.g first parameter is always $1, second is $2) or by other means... like I define that first parameter will be variable X so I can use that with if statements |
I believe there is no automated solution in Script server.
In my scripts i always used named parameters (e.g. -p1 xxx -p2 yyy) in such
cases
In Script server, you can accomplish it by using param field
But it would require some modifications of your script
There is a feature request: #181
I can implement it next week, probably
Nottt <notifications@github.com> schrieb am Mo., 23. Dez. 2019, 19:13:
… So what I should do to accomplish what I want? I don't want to clutter the
UI with lots of scripts
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#246?email_source=notifications&email_token=AAJXPJLUJW3SJWLR7F6O6WTQ2D5WNA5CNFSM4J6WCJH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHRUXWI#issuecomment-568544217>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJXPJJL2QTW3CULA4IMDULQ2D5WNANCNFSM4J6WCJHQ>
.
|
Sorry, may be it was confusing. The approach with "param" field is there
already
The feature request is for another approach, which will make everything way
easier for you
Yaroslav Shepilov <buggygm@gmail.com> schrieb am Mo., 23. Dez. 2019, 19:27:
… I believe there is no automated solution in Script server.
In my scripts i always used named parameters (e.g. -p1 xxx -p2 yyy) in
such cases
In Script server, you can accomplish it by using param field
But it would require some modifications of your script
There is a feature request:
#181
I can implement it next week, probably
Nottt ***@***.***> schrieb am Mo., 23. Dez. 2019, 19:13:
> So what I should do to accomplish what I want? I don't want to clutter
> the UI with lots of scripts
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#246?email_source=notifications&email_token=AAJXPJLUJW3SJWLR7F6O6WTQ2D5WNA5CNFSM4J6WCJH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHRUXWI#issuecomment-568544217>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAJXPJJL2QTW3CULA4IMDULQ2D5WNANCNFSM4J6WCJHQ>
> .
>
|
+1 for #181 😄 I think I'm using "param" wrong then.
With this script:
Doesn't work. |
Yes, it works differently, if you have parameters id and name, with the
values 123 and Nottt, for example, then the script will be called like this
myScript.sh id 123 name Nottt,
So $1 will be id, $2 = 123, $3 = name, $4 = Nottt
You can use getopts or alternatives to "parse" it
The feature request #181 is exactly about how you are trying to use it now
:) so you will have $ID and $NAME variables additionally
Nottt <notifications@github.com> schrieb am Mo., 23. Dez. 2019, 19:34:
… +1 for #181 <#181> 😄
I think I'm using "param" wrong then.
{
"name":"ID",
"type":"text",
"param":"id",
"required":false
},
{
"name":"Nome",
"type":"text",
"param":"name",
"required":false
}
With this script:
echo $id
echo $name
Doesn't work.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#246?email_source=notifications&email_token=AAJXPJLIT7G6P4R2ZVCJDP3Q2EAC5A5CNFSM4J6WCJH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHRVZEA#issuecomment-568548496>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJXPJOIU6SOULSH24QETHDQ2EAC5ANCNFSM4J6WCJHQ>
.
|
Thanks for the support! This is working:
In the script:
|
I added a ticket (#247) to address this problem in a different manner: by always passing parameters, even if they are empty |
Given those parameters, and a single script that will execute different stuff based if a ID or NAME is given how you would do this?
I can't use
if [ ! -z "$1" ]
for example. Because if someone only gives a name, it will be$1
and vice versa.I tried to use
"param":"2",
in my json because I thought that way I could control that$1
will always be a ID and $2 a NAMEThe text was updated successfully, but these errors were encountered: