Blacksmoke16 / oq

A performant, and portable jq wrapper to facilitate the consumption and output of formats other than JSON; using jq filters to transform the data.
https://blacksmoke16.github.io/oq/
MIT License
190 stars 15 forks source link

Support Multiple `--arg` flags #57

Closed oliverisaac closed 4 years ago

oliverisaac commented 4 years ago

This command fails:

oq --input=yaml -r --arg chart stolon --arg version 1.5.10 '$version' <<< "a: b"

With output:

oq error: Error opening file with mode 'r': '1.5.10': No such file or directory
jq: error: version/0 is not defined at <top-level>, line 1:
version
jq: 1 compile error

Whereas this should work:

jq -r --arg chart stolon --arg version 1.5.10 '$version' <<< '{"a": "b"}'
Blacksmoke16 commented 4 years ago

Hm, imma have to think about this a bit as it turns out it's a bit tricky. I think I'll need to refactor how ARGV is parsed in order to extract the oq arguments, collecting the rest to pass to jq, and leave only the file for ARGF to pickup.

~Possibly one solution that could make things easier is to make the file be it's own argument. Because of https://github.com/Blacksmoke16/oq/issues/16#issuecomment-513478548, supporting more than one file at a time is going to be unlikely so this could be a decent solution.~

EDIT: Nevermind, multiple files are supported so have to go back to the drawing board.

Blacksmoke16 commented 4 years ago

~New plan is to require the files to be passed after a ---.~

EDIT: Ended up just refactoring how ARGV is parsed to better handle files and multiple arguments.