google / google/python-fire

feature request: tell fire to stop parsing argument and pass the remaining unparsed args to function

未关闭
#403 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
enhancement
主要语言
Python
星标
28.2k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

描述

**Feature Description**

I am working on a tool to wrap some existed command line tools to make them easier to use (like auto install, inject argument automatically, etc). And I hope that I can have a way to tell Fire to stop parsing after encount some specific command.

**Example**
Here are some real world examples like `poetry run python3 ./my-scripts.py` or `conda run -n my-env python3 ./my-scripts.py`

Without this feature I can only put everything else as string, just like what `-c` option of `bash` does, e.g. `bash -c "echo 'hello world'" `, which could still work, but the user have to type extra string quote and dealing with escaping in some cases.

I am not sure if it is possbile to provide some decorator to archive this, for example

```python
class Conda:
def __init__(verbose=False):
...

@fire.decorators.SkipParse
def run(self, *argv):
print(argv)

fire.Fire(Conda)
```

And when running with `python fake-conda.py --verbose run which -a python3`, the output should be `('which', '-a', 'python3')`

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。