Windows (cmd.exe) で Ant の適切なタブ補完を行う方法はありますか?
デフォルトのターゲットを書き上げて、他のすべてのターゲットをリストすることもできますが、それは、たとえば Linux で得られる適切なタブ補完と同じではありません。
Windows (cmd.exe) で Ant の適切なタブ補完を行う方法はありますか?
デフォルトのターゲットを書き上げて、他のすべてのターゲットをリストすることもできますが、それは、たとえば Linux で得られる適切なタブ補完と同じではありません。
ant の tabcompletion は、powershell.exe に非常に簡単に統合できます。ちなみに、これは単純な古い cmd.exe よりもはるかに強力です。
Powershell.exe は Windows 7/8 の一部ですが、XP では別のコンポーネントとしてインストールすることもできます (Microsoft の Web サイトからダウンロードできます)。
https://github.com/peet/posh-antで提供されているスクリプトを使用しました。スクリプトはまだ完璧ではありませんが、仕事の 95% はうまくいきます。
BASH には、組み込みcomplete
コマンドにカスタマイズ可能な完了メカニズムがあります。完全なコマンドをスクリプト化することで、考えられるほぼすべてのコマンド ライン補完を実行できます。complete-ant-cmd.pl
Ant ターゲットの補完は、Cygwin のシステム全体の .bashrc ファイルに配置されていると呼ばれる Perl シェル スクリプトを介して行われます。
CMD.exe にはこのメカニズムがなく、既に組み込まれているものを超えて拡張することはできません。
他の人が述べたように、すべてのターゲットとその説明を一覧表示するant -p
orコマンドを試すことができます。ant --projecthelp
このbuild.xml
ファイルを試してください:
<project name="test" default="target2" basedir=".">
<description>
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.
</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
$
この機能は、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 属性が設定されている) を出力する一般的な方法です。これを行うためにデフォルトのターゲットを書くのではなく。