Skip to content

Instantly share code, notes, and snippets.

@raphink
Created November 21, 2012 08:52
Show Gist options
  • Save raphink/4123876 to your computer and use it in GitHub Desktop.
Save raphink/4123876 to your computer and use it in GitHub Desktop.
Proposition for a setlist API entry

Proposition for a setlist API entry

In order to easily manage multiple entries in the tree, it would be useful to have a setlist API entry, which would manage both named nodes as well as seq ones. It could look like this:

setlist <path> <label|seq> <replace|add|merge> <value> [value [value […]]]

For example, having /files/etc/ssh/sshd_config/AcceptEnv as:

{ "AcceptEnv"
  { "1" = "LC_*" } }

The following call:

setlist /files/etc/ssh/sshd_config/AcceptEnv seq replace LANG LC_*

would produce:

{ "AcceptEnv"
  { "1" = "LANG" }
  { "2" = "LC_*" } }

while

setlist /files/etc/ssh/sshd_config/AcceptEnv seq add LANG FOO

would result in:

{ "AcceptEnv"
  { "1" = "LC_*" }
  { "2" = "LANG" }
  { "3" = "FOO" } }

and

setlist /files/etc/ssh/sshd_config/AcceptEnv seq merge LANG LC_*

in

{ "AcceptEnv"
  { "1" = "LANG" }
  { "2" = "LC_*" } }

For non-seq entries, we could specify the label. For example, having /files/etc/group/audio set to:

{ "audio"
  { "password" = "x" }
  { "gid" = "29" }
  { "user" = "pulse" }
  { "user" = "rpinson" } }

we could do:

setlist /files/etc/group/audio user add foo bar

resulting in:

{ "audio"
  { "password" = "x" }
  { "gid" = "29" }
  { "user" = "pulse" }
  { "user" = "rpinson" }
  { "user" = "foo" }
  { "user" = "bar" } }

If the nodes need to be created on sublevels, you would use a slash in the label:

setlist /path/to/node entry/user replace foo bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment