google / google/python-fire

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

Đang mở
#403 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
28.2k
Fork
1.5k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**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')`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.