Skip to content

Support providing list and dictionary variables from command line. #2957

Closed as duplicate

Description

@aaltat

It's possible to provide scalar variables from command line:

--variable EXAMPLE:bar

But currently it's not possible to define list and dictionary variables from command line. To overcome the limitation, data can be passed as scalar variable or via variable file and then parse the data as list or dictionary. But it would be useful to make it possible to pass list and dict variables from the command line. Perhaps it would be good use same LIST__ and DICT__ prefixes that variable files support and then using Python's ast.literal_eval() to convert the valua to a list/dict. Something like this:

--variable "LIST__EXAMPLE:['foo', 'bar']"

Activity

  1. pekkaklarck commented on Sep 13, 2018

    @pekkaklarck
    Member

    This would be useful and shouldn't be overly complicated to implement. I doubt I have time for that personally in the near future, but if someone else is interested, there ought to be still time to get it into RF 3.1 even.

  2. added
    help wanted
    on Jan 14, 2019
  3. pekkaklarck commented on Jan 14, 2019

    @pekkaklarck
    Member

    Would be also handy to be able to use other non-string values. Not sure are custom objects worth the effort, but at least numbers, Booleans, None would be nice. I see two possibilities how to implement that:

    • Add a prefix like EVAL__ to mean that the value should be passed through ast.literal_eval. For example, --variable X:EVAL__42. This could be implemented as part of this issue.

    • Add support for using variables in the values. This would allow using the built-in variables to specify numbers, Booleans and None like --variable 'X:${42}'. Would also allow other possibly useful usages such as --variable HOST:1.2.3.4 --variable 'URL:http://${HOST}/example'. This would require its own issue.

  4. pekkaklarck commented on Aug 15, 2019

    @pekkaklarck
    Member

    Issue #2946 proposes adding support for non-string variable values from the CLI. That covers also lists/dicts so let's close this one as its duplicate.

  5. added and removed
    help wanted
    on Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions