google / google/python-fire

Behaviour of fire for variadic arguments

未關閉
#169 22 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
28.2k
分支
1.5k
PR 合併指標
30 天內沒有已合併 PR

描述

I have some codebase which uses argparse and wanted to migrate into python-fire. Now there I have option of specifying nargs as different flags to get required arguments. Now say I have one flag which uses '+' and one uses '*' to get arguments. How can I wrap all this stuff in a function so that fire converts into desired cli automatically. Actually I want to get variable size list for different flags.
Consider this testfire.py
```
def special(*args, **kwargs):
print(args)
print(kwargs)
```
python testfire.py special --par1 haha --par2 a b c
produces:
```
('b', 'c')
{'par1': 'haha', 'par2': 'a'}
```
I would like to achieve is that to be able to have these name of par1 and par2 integrated and for par2 I want to get a, b, c in list.
Thanks

貢獻指南

開啟貢獻指南

研究方向

Reproduce the behavior using the testfire.py example and the command `python testfire.py special --par1 haha --par2 a b c`. Then inspect how Python Fire parses variadic positional and named arguments, and compare the current output with the requested result where par2 contains a, b, and c while par1 remains named.】【。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
cli
Issue 類型
功能
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
28/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。