google / google/python-fire

First-character argument flag is undocumented and behaves strangely when colliding with default options

Đang mở
#238 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug documentation
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ả

Consider the function signature:

```
def main(headless=False):
# Construct GUI
if not headless:
widget.show()
app.exec()

if __name__ == '__main__': fire.Fire(main)
```

After reading through the user guide for fire, I would expect `python myFile -h` to produce the help signature for this file. However, it runs the script with `headless = True`.

While in retrospect I suppose this makes sense, I would like some way of telling fire to disallow shortcut flags if they override user-expected options like --[i]nteractive, --[h]elp, etc. In those cases, the user can be forced to say `python myFile --headless` for the desired behavior.

Moreover, if my script looked like this:
```
def main(headless=False, hArg=True):
# Construct GUI
if not headless:
widget.show()
app.exec()

if __name__ == '__main__': fire.Fire(main)
```
and I ran the same line of code, fire would appropriately err out. This is also acceptable in my opinion.

More importantly, the first-character flag behavior should at the very least be documented. I read through https://github.com/google/python-fire/blob/master/docs/guide.md and couldn't find it there.

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.