google / google/python-fire

feature request: a way to support nested dict input

オープン
#401 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
28.2k
フォーク
1.5k
PR マージ指標
30日以内にマージされた PR はありません

説明

## Background
Hi, I just come into a case that need to allow user to override some default value of a json configuration. The configuration is a nested dict and so is the input. I didn't find fire has good support for such case so here is a proposal.

## Feature
Take this as an example

```python
def my_command(config: dict):
...
```
I think fire may support such input to build the actual value of `config`

``` bash
my_command --config.pos.x=20 --config.pos.y=10
# or
my_command --config.pos='{"x": 20, "y":10}'
# or
my_command --config='{"pos": {"x": 20, "y":10}}'
```
And both will end up with the following dict
```python
{
"pos": { "x": 20, "y": 10}
}
```
The beauty of this design can avoid a lot of unecessary `"` and `{}` (and you need to pair them correctly) input of a JSON data. It's less error prone and comforable to use this style in command line. Currently I can handle this via kwargs, but I think it would be nice to have native support.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。