質問

Windows(cmd.exe)の下でアリに適切なタブを完了する方法はありますか?

デフォルトのターゲットを書き込み、他のすべてのターゲットをリストすることもできますが、たとえばLinuxで得られる適切なタブの完了と同じではありません。

役に立ちましたか?

解決

Bashには、ビルトインにカスタマイズ可能な完了メカニズムがあります complete 指図。完全なコマンドをスクリプトすることで、あなたが考えることができるほとんどすべてのコマンドラインの完了を行うことができます。 ANTターゲットの完了は、呼ばれるPerlシェルスクリプトを介して行われます complete-ant-cmd.pl これは、Cygwinのシステム全体のBashrcファイルに入れられます。

CMD.exeにはこのメカニズムがなく、すでに組み込まれているものを超えて拡張することはできません。

他の人が言及したように、あなたは試すことができます ant -p また ant --projecthelp すべてのターゲットとその説明をリストするコマンド。これを試して build.xml ファイル:

<project name="test" default="target2" basedir=".">
    <description>
         This is a test project. It is to demonstrate the use
         of the &quot;ant -p&quot; command and show all described
         targets. The "&quot;" probably won't work, but you can use
         regular quotes.
    </description>

    <target name="target1"
        description="This is the prime target, but not the default"/>

    <target name="target2"
        description="This is the default target but not because I said it here"/>

    <!-- Target "target3" won't display in "ant -p" because -->
    <!-- it has no description parameters. Life is tough.   -->

    <target name="target3"/>

    <target name="target4"
        description="This is target #4, but there's no target3"/>
 </project>

出力は次のとおりです。

$ ant -p
Buildfile: /Users/david/build.xml

    This is a test project. It is to demonstrate the use
    of the "ant -p" command and show all described
    targets. The """ probably won't work, but you can use
    regular quotes.

Main targets:

    target1  This is the prime target, but not the default
    target2  This is the default target but not because I said it here
    target4  This is target #4, but there's no target3
Default target: target2
$

他のヒント

PowerShell.exeでANTのTabCompleationを非常に簡単に統合できます。これは、普通のCMD.exeよりもはるかに強力です。

PowerShell.exeはWindows 7/8の一部ですが、XPに個別のコンポーネントとしてインストールすることもできます(Microsoft Webサイトからダウンロードできます)。

下に提供されたスクリプトを使用しました https://github.com/peet/posh-ant. 。スクリプトはまだ完璧ではありませんが、ジョブの95%が非常にうまく機能します。

この機能 Cygwin Bash環境で機能します Windowsで。

私は常にCygwinを使用しています。この機能については知りませんでした。しかし、そのリンクに記載されているように、プロファイルを更新した後、私は今それを試しました:

$ ant t<TAB>est<TAB>
test    test_1  test_2  test_3
$ ant test

CMD.exeがこの種のサポートをサポートしているとは思いません カスタマイズ可能なコマンド完了.

PowerShellでそのようなことができるかどうかは、私が答えることができない質問です。

ところで、「ant -P [rojecthelp]」は、ビルドファイルにターゲット(説明属性セットを持つ)を印刷する典型的な方法です。これを行うためにデフォルトのターゲットを書くのではなく。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top