Search code examples
cuelang

Is there a way to import pkgs as part of `cue eval -e`


I'm trying to run cue eval myfile.json -e and the expression includes regexp.FindSubmatch. This works fine if I do the add the expression to a cue file with the proper imports at the top, but I'm testing to see if I can bypass generating a cue file and basically use cue in place of jq.

Is there a way with the cue cli to inject the import statements as flags or in the expression string?


Solution

  • Hmmm, this works out-of-the-box for me:

    $ cat /tmp/a.json | jq
    {
      "a": "foobar"
    }
    
    $ cue eval /tmp/a.json -e 'regexp.FindSubmatch(".o.", a)'
    ["foo"]
    
    $ cue version
    cue version v0.4.3 darwin/amd64
    

    Did you mean a different use case?