1

Windows (cmd.exe) で Ant の適切なタブ補完を行う方法はありますか?

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

4

3 に答える 3

3

ant の tabcompletion は、powershell.exe に非常に簡単に統合できます。ちなみに、これは単純な古い cmd.exe よりもはるかに強力です。

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

https://github.com/peet/posh-antで提供されているスクリプトを使用しました。スクリプトはまだ完璧ではありませんが、仕事の 95% はうまくいきます。

于 2012-12-07T11:40:01.267 に答える
2

BASH には、組み込みcompleteコマンドにカスタマイズ可能な完了メカニズムがあります。完全なコマンドをスクリプト化することで、考えられるほぼすべてのコマンド ライン補完を実行できます。complete-ant-cmd.plAnt ターゲットの補完は、Cygwin のシステム全体の .bashrc ファイルに配置されていると呼ばれる Perl シェル スクリプトを介して行われます。

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

他の人が述べたように、すべてのターゲットとその説明を一覧表示するant -porコマンドを試すことができます。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
$
于 2011-06-21T14:10:55.793 に答える
1

この機能は、Windowsの Cygwin bash 環境で動作します。

私は常にCygwinを使用しています。この機能を知らず、有効にしていませんでした。しかし、そのリンクで説明されているようにプロファイルを更新した後、今試してみました。

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

cmd.exe がこの種のカスタマイズ可能なコマンド補完をサポートしているとは思わない。

PowerShell でそのようなことができるかどうかは、私には答えられません。

ところで、「ant -p[rojecthelp]」は、ビルド ファイル内のターゲット (description 属性が設定されている) を出力する一般的な方法です。これを行うためにデフォルトのターゲットを書くのではなく。

于 2011-06-21T12:25:26.270 に答える