魚の完成 - ファイルの完成を防ぐ方法は?

魚の完成 - ファイルの完成を防ぐ方法は?

内部ツール用のいくつかの完成版を作成しようとしています。それが私たちが呼ぶものですthetool

多くのコマンドはthetool「ファイル」を引数として使用しません。私アイデアそれは--no-filesそして/または--exclusive私のためにそれをしますが、私はそれがうまくいくことができないようです。

つまり、次のコマンドがタブの完成にファイルを表示するように完成をどのように作成しますか?

$ thetool file-command *hit-tab*

次のコマンドは、タブの完了時にファイルを表示しません。

$ thetool non-file-command *hit-tab*

おもちゃの例を試してみましょう。

$ function thetool
    echo $argv
  end
$ complete --command thetool --no-files --condition "not __fish_seen_subcommand_from file-command non-file-command" --arguments "file-command" --description "file-command"
$ complete --command thetool --no-files --condition "not __fish_seen_subcommand_from file-command non-file-command" --arguments "non-file-command" --description "non-file-command"
$ complete --command thetool
complete --no-files thetool -d non-file-command -a non-file-command -n 'not __fish_seen_subcommand_from file-command non-file-command'
complete --no-files thetool -d file-command -a file-command -n 'not __fish_seen_subcommand_from file-command non-file-command'

それでは、以下を完了してみてください。

$ thetool *hit-tab*
file-command  (file-command)  non-file-command  (non-file-command)

これまでは大丈夫に見えますが…

$ thetool non-file-command *hit-tab*
bin/                  dev.yml       Judgment.lock  README.md              TODO.md           
completion_test.fish  exe/          lib/           shipit.production.yml  vendor/           
completion_test.zsh   Gemfile       linters/       sorbet/                zsh_completions.sh
coverage/             Gemfile.lock  Rakefile       test/                  

望むより!これらの文書はそこで何を提案しますか?

もう一度やりましょう:

$ complete --command thetool --force-files --condition "not __fish_seen_subcommand_from file-command non-file-command" --arguments "file-command" --erase
$ complete --command thetool --force-files --condition "not __fish_seen_subcommand_from file-command non-file-command" --arguments "file-command"
$ complete --command thetool --no-files --condition "not __fish_seen_subcommand_from file-command non-file-command" --arguments "non-file-command"
$ complete --command thetool
complete --no-files thetool -a non-file-command -n 'not __fish_seen_subcommand_from file-command non-file-command'
complete --force-files thetool -a file-command -n 'not __fish_seen_subcommand_from file-command non-file-command'
$ thetool *hit-tab*
bin/                  dev.yml       Gemfile.lock   non-file-command       sorbet/  zsh_completions.sh
completion_test.fish  exe/          Judgment.lock  Rakefile               test/    
completion_test.zsh   file-command  lib/           README.md              TODO.md  
coverage/             Gemfile       linters/       shipit.production.yml  vendor/  

arrg現在の状況と私が間違っていることを理解するのに役立つ人がいますか?

ベストアンサー1

魚がそれを見るならnon-file-command

それらを見てみましょう:

complete --command thetool --no-files --condition "not __fish_seen_subcommand_from file-command non-file-command" --arguments "file-command" --description "file-command"

持つnon-file-command条件が偽であることがわかります。

complete --command thetool --no-files --condition "not __fish_seen_subcommand_from file-command non-file-command" --arguments "non-file-command" --description "non-file-command"

持つnon-file-command条件が偽であることがわかります。

complete --command thetool

これはうまくいきません。

complete --no-files thetool -d non-file-command -a non-file-command -n 'not __fish_seen_subcommand_from file-command non-file-command'

持つnon-file-command条件が偽であることがわかります。

complete --no-files thetool -d file-command -a file-command -n 'not __fish_seen_subcommand_from file-command non-file-command'

持つnon-file-command条件が偽であることがわかります。

ファイルの無効化条件は維持されないため、デフォルトで有効にします。指定した場合、non-file-commandファイルを無効にするように求められません。

次へ追加

complete --command thetool --no-files --condition " __fish_seen_subcommand_from non-file-command"

動作します。

それとも物事が多い場合いいえ追加できるファイルといくつかのファイルをインポートする

complete --command thetool --no-files

これによりファイルが無効になります。いつも(無条件なので完了する限り常に正確ですthetool。) その後、条件付きの場合は強制的に保管してください。

complete --command thetool --condition "__fish_seen_subcommand_from file-command" --force-files

おすすめ記事