在Windows下完成标签为Ant?
-
27-09-2019 - |
题
是否有任何方式具有用于蚂蚁下窗口(cmd.exe的)一个适当的标签完成?
我可以写了默认的目标列出所有的其他目标,但是这只是没有同适当的标签完成你在Linux上的实例。
解决方案
bash有在内置complete
命令可定制完成的机制。通过脚本完整的命令,你可以做几乎任何你能想到的命令行完成。蚂蚁目标完成经由其被放置在Cygwin的系统宽的bashrc文件一个Perl外壳脚本称作complete-ant-cmd.pl
进行。
的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 "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
$
其他提示
您可以很容易地在powershell.exe整合为蚂蚁tabcompletion,它的方式比普通的旧的cmd.exe更强大。
Powershell.exe是视窗7/8的一部分,但也可以在XP(可从Microsoft网页下载)被安装为独立的组件。
我用下 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是一个问题,我不能回答。
顺便说一句,“蚂蚁-p [rojecthelp]”是在生成文件打印的目标(其具有描述属性集)的典型方式。而不是写默认目标要做到这一点。
不隶属于 StackOverflow