completamento automatico per Ant sotto Windows?
-
27-09-2019 - |
Domanda
C'è un modo per avere un completamento scheda adeguata per Ant sotto le finestre (cmd.exe)?
Potrei scrivere la destinazione predefinita per elencare tutti gli altri obiettivi, ma questo è solo non lo stesso di una corretta compilazione scheda si ottiene su Linux per esempio.
Soluzione
BASH ha un meccanismo di completamento personalizzabile nel comando integrato complete
. Con script il comando completo, si potrebbe fare il completamento della linea di comando su quasi tutto ciò che si può pensare. Il completamento di destinazione formica è fatto tramite uno script Perl shell chiamato complete-ant-cmd.pl
che viene messo nel file system ampia .bashrc in Cygwin.
CMD.exe non ha questo meccanismo e non può essere espansa al di là di ciò che è già integrato in esso.
Come altri hanno detto, si può provare il comando ant -p
o ant --projecthelp
che elencherà tutti gli obiettivi e la loro descrizione. Prova questo file 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>
L'output sarà:
$ 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
$
Altri suggerimenti
È possibile integrare tabcompletion per formica abbastanza facilmente in powershell.exe, che tra l'altro è molto più potente rispetto al vecchio cmd.exe pianura.
Powershell.exe fa parte di Windows 7/8 ma può anche essere installato come componente separato in XP (può essere scaricato dal sito Web di Microsoft).
ho usato lo script fornito sotto https://github.com/peet/posh-ant. Lo script non è ancora perfetto, ma lo fa il 95% del lavoro abbastanza bene.
Questa funzione opere in Cygwin bash ambiente su Windows.
Io uso Cygwin per tutto il tempo. Non sapevo nulla e non aveva permesso questa funzione. Ma ho provato solo ora dopo aver aggiornato il mio profilo come descritto in tale link:
$ ant t<TAB>est<TAB>
test test_1 test_2 test_3
$ ant test
Non credo che supporti questo tipo di cmd.exe comando personalizzabile completamento .
Sia che si potrebbe fare qualcosa di simile con PowerShell è una domanda a cui non posso rispondere.
A proposito, "formica -p [rojecthelp]" è il tipico modo per stampare gli obiettivi (che hanno Descrizione attributo set) nel file build. Piuttosto che scrivere un obiettivo predefinito per fare questo.