Windows 下 Ant 的 Tab 补全功能?
有没有办法让 Ant 在 Windows 下(cmd.exe)有正确的制表符补全?
我可以编写默认目标来列出所有其他目标,但这与您在 Linux 上获得的正确制表符补全不同。
Is there any way to have a proper tab completion for Ant under windows (cmd.exe) ?
I could write up the default target to list all the other targets, but that's just no the same as a proper tab completion you get on linux for instance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在 powershell.exe 中轻松集成 ant 的 tabcompletion,顺便说一下,它比普通的旧 cmd.exe 强大得多。
Powershell.exe 是 Windows 7/8 的一部分,但也可以在 XP 中作为单独的组件安装(可以从 Microsoft 网站下载)。
我使用了 https://github.com/peet/posh-ant 下提供的脚本。该脚本尚不完美,但已经完成了 95% 的工作。
You can integrate tabcompletion for ant quite easily in powershell.exe, which by the way is much more powerful than the plain old cmd.exe.
Powershell.exe is part of Windows 7/8 but also can be installed as separate component in XP (can be downloaded from the Microsoft website).
I used the script provided under https://github.com/peet/posh-ant. The script is not yet perfect, but does 95% of the job quite well.
BASH 在内置的
complete
命令中有一个可定制的完成机制。通过编写完整命令的脚本,您几乎可以对您能想到的任何内容进行命令行完成。 ant 目标补全是通过名为complete-ant-cmd.pl
的 Perl shell 脚本完成的,该脚本位于 Cygwin 中的系统范围 bashrc 文件中。CMD.exe 没有这种机制,并且无法扩展到超出其内置功能的范围。
正如其他人提到的,您可以尝试使用
ant -p
或ant --projecthelp
命令来列出所有目标及其描述。尝试这个build.xml
文件:输出将是:
BASH has a customizable completion mechanism in the builtin
complete
command. By scripting the complete command, you could do command line completion on almost anything you can think of. The ant target completion is done via a Perl shell script calledcomplete-ant-cmd.pl
which is put in the system wide bashrc file in Cygwin.CMD.exe does not have this mechanism and it cannot be expanded beyond what is already built into it.
As others have mentioned, you can try the
ant -p
orant --projecthelp
command that will list all targets and their description. Try thisbuild.xml
file:The output will be:
此功能适用于 Windows 上的 Cygwin bash 环境。
我一直使用 Cygwin。不知道也没有启用此功能。但我在按照该链接所述更新我的个人资料后刚刚尝试过:
我不认为 cmd.exe 支持这种类型 可自定义的命令完成。
我无法回答是否可以使用 PowerShell 做类似的事情。
顺便说一句,“ant -p[rojecthelp]”是在构建文件中打印目标(设置了描述属性)的典型方法。而不是编写默认目标来执行此操作。
This feature works in the Cygwin bash environment on Windows.
I use Cygwin all the time. Didn't know about and hadn't enabled this feature. But I tried it just now after updating my profile as described in that link:
I don't think that cmd.exe supports this kind of customizable command completion.
Whether you could do something like it with PowerShell is a question I can't answer.
BTW, "ant -p[rojecthelp]" is the typical way to print the targets (which have description attribute set) in your build file. Rather than writing a default target to do this.