Getopt :: commalllineexports.

Consentire Suroutine all'interno di uno script per esportare le opzioni di linea COMAND con Completamento automatico di Bash
Scarica ora

Getopt :: commalllineexports. Classifica e riepilogo

Annuncio pubblicitario

  • Rating:
  • Licenza:
  • Perl Artistic License
  • Prezzo:
  • FREE
  • Nome editore:
  • Robert Haxton
  • Sito web dell'editore:
  • http://search.cpan.org/~rhaxton/

Getopt :: commalllineexports. Tag


Getopt :: commalllineexports. Descrizione

GetOPT :: CommandOnlineExports è un modulo Perl destinato a fornire la capacità di avere un singolo script esportare molte sottocomando in modo coerente. Nell'esempio sopra, lo script è denominato "TestCommandlineexports". Su una riga di comando di stile Bash, i seguenti comandi funzionerebbero: TestCommandLineeExports TwosCALARS --On "Arg1" --Two "arg2" e sarebbe stampato: arg1, arg2wiletcommandlineexports twoscalars --two "arg2" stampato: TwosCALARS MANCANTE ARGOMENTO NECESSARIO: --NetestCommandLineExports TwosCALARS può anche essere chiamato anche attraverso un'interfaccia CGI. Il principio uso di questo è stato quello di fornire un metodo facile, consistente, per fornire la capacità di prova dell'unità per gli script. Permette inoltre di esportare un singolo script per esportare più sottocomando e, con la funzione di completamento automatico di Bash Auto incluso, consente alle sottocomando e alle opzioni di integrare bene con il codice Bash Shell.synopsisexample; utilizzare rigoroso; Utilizzare Avvertenze; Utilizzare Getopt :: CommandLineExports QW (Regac ParseargsByposition Pasheargs Checkargs $ ScriptName @Exportedsubs% cmdlines); $ scriptName = QQ ; % cmdlines = (twoscalars => , onehash => , onelist => ,); sub twoscalars {my% h = (one => undef, due => nonf, (Parseargs \ @_, @ {$ cmdlines {twoscalars}}),); Stampa "TWOCALARS MANCANTE ARGOMENTO NECESSARIO: \ n". Unisciti a ("\ n", checkargs \% h). "\ n" se (checkargs \% h); ritorno "$ h {one}, $ h {due} \ n"; } sub onehash {my% h = (one => undef, (Parseargs \ @_, @ {$ cmdlines {onehash}}),); Stampa "Onehash mancante argomento richiesto: \ n". Unisciti a ("\ n", checkargs \% h). "\ n" se (checkargs \% h); Stampa "Onehash \ n"; Stampa join ("\ n", (% {$ h {one}})); } sub onelist {my% h = (one => undef, (Paseargs \ @_, @ {$ cmdlines {onelist}}),); Stampa "Ondalist mancante argomento richiesto: \ n". Unisciti a ("\ n", checkargs \% h). "\ n" se (checkargs \% h); stampa "onelist \ n"; Stampa Iscriviti ("\ n", @ {$ h {one}}); } # # La subroutine "principale". Non incluso nel pacchetto, deve essere aggiunto manualmente in uno script se (definito $ argv ) {se (definito ({$ argv })) {non rigoroso 'refs'; My $ SURREF = SHIFT @ARGV; Stampa Iscriviti ("\ n", $ subref (@argv)). "\ n" a meno che $ subref = ~ / regac /; $ subref ($ scriptname, \ @exportedsubs, \% cmdlines) se $ SURREF = ~ / regac /; uscita 0; }} # Alcuni esempi di test unitario: TWOCALARS "Hello1", "Ciao2"; twoscalars {one => "hello1", due => "hello2"}; TWOCALARS "--On hello1 --two hello2"; TWOCALARS "--On", "ciao1", "--two", "ciao2"; TWOCALARS "--On", "ciao1", "--two", "hello2", "--three", "ciao3"; # Lamenta di "Opzione sconosciuta: Tre" Homepage del prodotto


Getopt :: commalllineexports. Software correlato