ssato / python-anyconfig

Python library provides common APIs to load and dump configuration files in various formats
MIT License
277 stars 31 forks source link

add support to load data from stdin to anyconfig_cli #100

Closed ssato closed 5 years ago

ssato commented 5 years ago

It would be nice if anyconfig_cli can load data from stdin such like:

$ cat /etc/foo.yml | anyconfig_cli -I yaml - -O json -o -
{"a": 1, "b": [1, 2], "c": "CCC"}
ssato commented 5 years ago

It should work by some recent commits such as 30680e7. Here is an example.

$ cat tests/res/00-01-cnf.json
{"b": {"b": [1, 2], "c": "C"}}
$ cat tests/res/00-01-cnf.json | PYTHONPATH=. python3 anyconfig/cli.py -I json -O yaml -
b:
  b:
  - 1
  - 2
  c: C
$ cat tests/res/00-01-cnf.json | PYTHONPATH=. python3 anyconfig/cli.py -I json -O yaml - --set b.c=AAA
b:
  b:
  - 1
  - 2
  c: AAA
$