You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Variable type conversion with command line variables #2946
Currently it is only possible to set strings on command line e.g. --variable foo:bar but there is no documented syntax to set up other data types. To be able to set lists and dictionaries would be handy on some cases, for instance.
Generic prefix to mean that the value should be evaluated in Python. Could be something like EVAL__ or PYTHON__.
Some other way to specify the type. Syntax inspired by function annotations line --variable VAR:int:42 could work. Should use the same with lists and dicts as well.
Support Robot's variables in values. That would allow e.g. integers like --variable 'VAR:${42}' and also support possible useful usages like -v VAR:foo -v VAR2:${VAR}bar.
Especially if we go with the option 3, we should use the new type conversion code to handle the values. We could then consider using the same syntax in the test data as well:
I closed #2957 as a duplicate of this issue. If we add support for non-string variable values from the CLI, we definitely should support lists and dicts as well as numbers and Booleans.
Prefixes like INT__ and LIST__ or the generic EVAL__ are all pretty ugly.
Postfix used like --variable VAR:int:42 look much better. Supporting them in the Variables section the test data as proposed the comment above would be super useful as well but should get its own issue.
Being able to use variables on the CLI like --variable 'VAR:${42}' could be useful as well. It wouldn't support lists/dicts, though, but being able to refer to earlier variables like -v HOST:1.2.3.4 -v 'URL:http://${HOST}/example' would be handy.
I'd say we should go with the <name>:<type>:<value> design. For backwards compatibility reasons we cannot make the <type> part mandatory, though, and should handle situation where the value contains colons like -v URL:http://.... Basically we should use the type information only if we recognize the part between colons.
The more I think about this, the more I like the <name>:<type>:<value> syntax. It would also work great with the proposed variable/argument type conversion in test data (#3278). These issues should probably be designed and also implemented together. Especially the latter is too big for RF 3.2 (unless we get external help), and I think this one should be moved from its scope as well.
Variable type conversion has been implemented and will be part of RF 7.3 (#3278). When designing it with @aaltat , we discussed also about command line variables but later forgot about them. Let's add that support in RF 7.4.
changed the title [-]Variable type conversion wiht command line variables[/-][+]Variable type conversion with command line variables[/+]on May 20, 2025
I prototyped this and this turned out to be very easy to implement using syntax name: type:value that, as discussed above, ought to be mostly backwards-compatible. I consider this so important part of the overall variable type conversion that I'll add this to RF 7.3 and create rc3 once this is ready.
Activity
aaltat commentedon Sep 22, 2018
Are you looking similar what is proposed in the #2957 ? If you aren't, could you explain what you are actually want?
pekkaklarck commentedon Sep 23, 2018
#2957 covers lists and dicts, but supporting also other base types, mainly numbers and Booleans, could be handy as well. Possible solutions:
Separate prefixes such as
INT__similarly as Support providing list and dictionary variables from command line. #2957 proposesLIST__.Generic prefix to mean that the value should be evaluated in Python. Could be something like
EVAL__orPYTHON__.Some other way to specify the type. Syntax inspired by function annotations line
--variable VAR:int:42could work. Should use the same with lists and dicts as well.Support Robot's variables in values. That would allow e.g. integers like
--variable 'VAR:${42}'and also support possible useful usages like-v VAR:foo -v VAR2:${VAR}bar.pekkaklarck commentedon Sep 23, 2018
Especially if we go with the option 3, we should use the new type conversion code to handle the values. We could then consider using the same syntax in the test data as well:
pekkaklarck commentedon Aug 15, 2019
I closed #2957 as a duplicate of this issue. If we add support for non-string variable values from the CLI, we definitely should support lists and dicts as well as numbers and Booleans.
Thinking this again and looking at the possible solutions I listed above my current thinking is that:
Prefixes like
INT__andLIST__or the genericEVAL__are all pretty ugly.Postfix used like
--variable VAR:int:42look much better. Supporting them in the Variables section the test data as proposed the comment above would be super useful as well but should get its own issue.Being able to use variables on the CLI like
--variable 'VAR:${42}'could be useful as well. It wouldn't support lists/dicts, though, but being able to refer to earlier variables like-v HOST:1.2.3.4 -v 'URL:http://${HOST}/example'would be handy.I'd say we should go with the
<name>:<type>:<value>design. For backwards compatibility reasons we cannot make the<type>part mandatory, though, and should handle situation where the value contains colons like-v URL:http://.... Basically we should use the type information only if we recognize the part between colons.aaltat commentedon Aug 15, 2019
I also like the
<name>:<type>:<value>syntax and give my vote for it.pekkaklarck commentedon Oct 16, 2019
The more I think about this, the more I like the
<name>:<type>:<value>syntax. It would also work great with the proposed variable/argument type conversion in test data (#3278). These issues should probably be designed and also implemented together. Especially the latter is too big for RF 3.2 (unless we get external help), and I think this one should be moved from its scope as well.pekkaklarck commentedon May 20, 2025
Variable type conversion has been implemented and will be part of RF 7.3 (#3278). When designing it with @aaltat , we discussed also about command line variables but later forgot about them. Let's add that support in RF 7.4.
6 remaining items
[-]Variable type conversion wiht command line variables[/-][+]Variable type conversion with command line variables[/+]pekkaklarck commentedon May 20, 2025
I prototyped this and this turned out to be very easy to implement using syntax
name: type:valuethat, as discussed above, ought to be mostly backwards-compatible. I consider this so important part of the overall variable type conversion that I'll add this to RF 7.3 and create rc3 once this is ready.pekkaklarck commentedon May 20, 2025
Documenting this will be done as part of documenting #3278.
Command line variable conversion
Enhance command line variable conversion test