BUG: When using a Class for grouping commands `--self` shows as a flag
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu với fire/completion.py và tái hiện ví dụ bằng python3 example.py -- --completion. Theo dõi cách các phương thức của lớp được chuyển thành các tùy chọn hoàn thành, sau đó xác minh rằng phần hoàn thành Bash được tạo ra không còn liệt kê --self cho bar hoặc do-stuff, đồng thời vẫn giữ lại --arg1.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Example code (example.py):
import fire
class Foo:
def bar(self):
return 'bar'
def do_stuff(self, arg1):
return 'stuff'
if __name__ == '__main__':
fire.Fire(Foo)
Run:
python3 example.py -- --completion
Completion Output (take note of --self in output):
# bash completion support for example.py
# DO NOT EDIT.
# This script is autogenerated by fire/completion.py.
_complete-examplepy()
{
local cur prev opts lastcommand
COMPREPLY=()
prev="${COMP_WORDS[COMP_CWORD-1]}"
cur="${COMP_WORDS[COMP_CWORD]}"
lastcommand=$(get_lastcommand)
opts=""
GLOBAL_OPTIONS=""
case "${lastcommand}" in
bar)
if is_prev_global; then
opts="${GLOBAL_OPTIONS}"
else
opts="--self ${GLOBAL_OPTIONS}"
fi
opts=$(filter_options $opts)
;;
do-stuff)
if is_prev_global; then
opts="${GLOBAL_OPTIONS}"
else
opts="--arg1 --self ${GLOBAL_OPTIONS}"
fi
opts=$(filter_options $opts)
;;
example.py)
opts="bar do-stuff ${GLOBAL_OPTIONS}"
opts=$(filter_options $opts)
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
get_lastcommand()
{
local lastcommand i
lastcommand=
for ((i=0; i < ${#COMP_WORDS[@]}; ++i)); do
if [[ ${COMP_WORDS[i]} != -* ]] && [[ -n ${COMP_WORDS[i]} ]] && [[
${COMP_WORDS[i]} != $cur ]]; then
lastcommand=${COMP_WORDS[i]}
fi
done
echo $lastcommand
}
filter_options()
{
local opts
opts=""
for opt in "$@"
do
if ! option_already_entered $opt; then
opts="$opts $opt"
fi
done
echo $opts
}
option_already_entered()
{
local opt
for opt in ${COMP_WORDS[@]:0:COMP_CWORD}
do
if [ $1 == $opt ]; then
return 0
fi
done
return 1
}
is_prev_global()
{
local opt
for opt in $GLOBAL_OPTIONS
do
if [ $opt == $prev ]; then
return 0
fi
done
return 1
}
complete -F _complete-examplepy example.py
- 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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/python-fire
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
google/python-fire#693 ·
-
Release 0.7.2? Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
google/python-fire#698 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
google/python-fire#672 · 5 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
google/python-fire#665 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
google/python-fire#659 · 1 bình luận ·
Tất cả issue của google/python-fire
Issue tương tự
-
货币战争手改优先级配置缺少列表元素类型校验(P3) Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Đang mởarea: ci bug perceived difficulty: 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ClickHouse/clickhouse-connect#1057 ·