tweag / nickel

Better configuration for less
https://nickel-lang.org/
MIT License
2.23k stars 85 forks source link

Inconsistent behaviour while loading multiple files vs single file #1901

Closed olorin37 closed 2 months ago

olorin37 commented 2 months ago

Problem

I found inconsistency, while loading two or more files any importable (json, yaml, toml) can be used otherwise only nickel file is allowed (examples works both for eval or export sub-commands):

nickel export my.yaml my.ncl    # => works

It works, does merge of two imported objects underneath as (import "my.yaml") & (import "my.ncl"). It is also works even there is no nickel file for example:

nickel export my.yaml my.toml my.json    # => works

But if we use only one file, it doesn't as it expects nickel syntax:

nickel export my.yaml    # => fails
nickel export my.toml    # => fails
nickel export my.json    # => fails

Solution?

  1. One, a little stupid idea is to import file even if this is only one file. Then we got consistent behaviour and also all files will be accepted. Actually I prefer this (it allows "abuse" of nickel as format converter: nickel export -f toml my.yaml -o my.toml.
  2. Disallow other than native, nickel files to be provided as an input, by a validation.

What you think?

yannham commented 2 months ago

Hello,

There is absolutely no good reason behind Nickel not accepting a yaml, json or toml file as a single input indeed, nor there is any technical limitation. It's sensible and is easy to implement, so we'll definitely do that :slightly_smiling_face:

yannham commented 2 months ago

Fixed in #1902.