nickel icon indicating copy to clipboard operation
nickel copied to clipboard

Add `--format` argument to `nickel query` command

Open suimong opened this issue 6 months ago • 4 comments

Closes #1976

This PR adds the ability for nickel query to export the result to JSON, YAML & TOML, similar to that of nickel export. The output schema looks like:

{
  doc | Nullable String,
  "optional" | Bool,
  not_exported | Bool,
  priority | String,   # variants include: "default", "neutral", "force", and string representation of rational number ("1", "5/2", etc.)
  type | Nullable String,
  contracts | Array String,
  sub_fields | Nullable (Array String),
  value | String | optional,
}

During implementation, I found a few areas that ask for "designing":

  • whether to use Nullable T or T | optional for some fields in the output schema
  • how to serialize the priority field
  • the logic that dictates the presence of the value field

suimong avatar Jul 29 '24 09:07 suimong