snowfallorg / nix-editor

A simple rust program to edit NixOS configuration files with just a command
MIT License
74 stars 6 forks source link

interface could be better - similar to jq #13

Closed milahu closed 2 years ago

milahu commented 2 years ago

the interface could be better - similar to jq

$ echo '{}' | jq  # identity
{}

$ echo '{}' | jq -c '.a=1 | .b=2' # set multiple values
{"a":1,"b":2}

$ echo '{}' | jq -c '.a=1 | .b=2' | jq -c '.c=3 | .d=4' # chaining
{"a":1,"b":2,"c":3,"d":4}

set multiple values

5

see also jaq - A jq clone focussed on correctness, speed, and simplicity

vlinkz commented 2 years ago

I feel that since the current argument structure has been around for a bit I wouldn't want to just change it now, however for a more minimal solely command-line focuses tool could be made using nix-editor as a crate since all of the important functions are public exports, maybe nix-editor-ng or something? Also reminds me I really need to write some documentation explaining everything

milahu commented 2 years ago

just bump the major version to release a new API

vlinkz commented 2 years ago

I really don't want to change the interface as it is right now, as it already does what it is supposed to do. I'm open to adding features, but don't want to make many major changes to the interface at this moment.

As for multiple values being set, I'll look into implementing the method I described in #5

That being said the main goal of this project is to provide a crate module for other tools to easily manage and edit .nix files, so while I don't currently have plans of making a jq-like tool, I would definitely support anyone who had an interest in doing so