Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / test / ClixTest.groovy @ 812

History | View | Annotate | Download (2.3 kB)

1
/**
2
 * Main.
3
 *
4
 * @param args the args
5
 */
6
// Copyright © 2010-2013 ENS de Lyon.
7
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
8
// Lyon 2, University of Franche-Comté, University of Nice
9
// Sophia Antipolis, University of Paris 3.
10
// 
11
// The TXM platform is free software: you can redistribute it
12
// and/or modify it under the terms of the GNU General Public
13
// License as published by the Free Software Foundation,
14
// either version 2 of the License, or (at your option) any
15
// later version.
16
// 
17
// The TXM platform is distributed in the hope that it will be
18
// useful, but WITHOUT ANY WARRANTY; without even the implied
19
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20
// PURPOSE. See the GNU General Public License for more
21
// details.
22
// 
23
// You should have received a copy of the GNU General
24
// Public License along with the TXM platform. If not, see
25
// http://www.gnu.org/licenses.
26
// 
27
// 
28
// 
29
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun. 06 mai 2013) $
30
// $LastChangedRevision: 2386 $
31
// $LastChangedBy: mdecorde $ 
32
//
33
package org.txm.test
34

    
35
/**
36
 * How to use ProcessBuilder to wrap an external program
37
 * 
38
 * 
39
 * ======= Definition file =======
40
<?xml version="1.0" encoding="UTF-8"?>
41
<application name="Ls" version="0.0.0" desc="List directory">
42
        <progs>
43
                <prog exec="ls" version="0.0.0" desc="Ls">
44
                        <args>
45
                                <arg state="optional" type="none" name="l" desc="use a long listing format"/>
46
                                <arg state="optional" type="none" name="a" desc="do not ignore entries starting with '.'"/>
47
                                <arg state="optional" type="String" name="d" desc="list directory entries instead of contents"/>
48
                        </args>
49
                </prog>
50
        </progs>
51
</application>
52
 * 
53
 */
54

    
55
/**
56
 * the file containing the declaration of the Ls program : ls-wrapper-definition.xml
57
 *
58
 */
59
def definitionFile = new File("~/workspace/org.txm.core/src/groovy/org/textometrie/scripts/ls-wrapper-definition.xml")
60

    
61
/**
62
 * The file which will contain the code : Ls.groovy
63
 */
64
def classFile = new File("~/Ls.groovy")
65

    
66
/**
67
 * the directory containing the binaries which will be called: /bin/
68
 */
69
def binariesDirectory = new File("/bin/")
70

    
71
/**
72
 * build wrapping code
73
 */
74
def aProgram = org.txm.utils.processbuilder.ProcessBuilder.wrapProgram(definitionFile, classFile, binariesDirectory)
75

    
76
/**
77
 * set call parameters
78
 */
79
aProgram.setl()
80
aProgram.seta()
81

    
82
/**
83
 * call the ls external program
84
 */
85
aProgram.ls()
86