1
- package javaxt .orm ;
2
- import java .util .*;
3
- import javaxt .io .Jar ;
4
- import static javaxt .utils .Console .console ;
5
-
6
- //******************************************************************************
7
- //** Main
8
- //******************************************************************************
9
- /**
10
- * Command line interface used to parse a model file and generate Java and SQL
11
- * output files.
12
- *
13
- ******************************************************************************/
14
-
15
- public class Main {
16
-
17
-
18
- //**************************************************************************
19
- //** main
20
- //**************************************************************************
21
- /** Entry point for the application
22
- * @param arguments Command line arguments
23
- */
24
- public static void main (String [] arguments ) throws Exception {
25
- HashMap <String , String > args = console .parseArgs (arguments );
26
-
27
-
28
- //Print version as needed
29
- if (args .containsKey ("-version" )){
30
- Jar jar = new Jar (Main .class );
31
- javaxt .io .File jarFile = new javaxt .io .File (jar .getFile ());
32
- String version = jar .getVersion ();
33
- if (version ==null ) version = "Unknown" ;
34
- System .out .println (jarFile .getName (false ) + " version \" " + version + "\" " );
35
- return ;
36
- }
37
-
38
-
39
- //Parse inputs
40
- String input = args .get ("-input" );
41
- String output = args .get ("-output" );
42
- if (input ==null ){
43
- input = arguments [0 ];
44
- if (arguments .length >1 ) output = arguments [1 ];
45
- }
46
- javaxt .io .File inputFile = new javaxt .io .File (input );
47
- if (!inputFile .exists ()) throw new IllegalArgumentException ("Input file not found" );
48
- javaxt .io .Directory outputDirectory = output ==null ?
49
- inputFile .getDirectory () : new javaxt .io .Directory (output );
50
-
51
-
52
- //Create models
53
- Model [] models = new Parser (inputFile .getText ()).getModels ();
54
-
55
-
56
- //Create files
57
- Writer .write (models , outputDirectory );
58
- }
1
+ package javaxt .orm ;
2
+ import java .util .*;
3
+ import javaxt .io .Jar ;
4
+ import static javaxt .utils .Console .console ;
5
+
6
+ //******************************************************************************
7
+ //** Main
8
+ //******************************************************************************
9
+ /**
10
+ * Command line interface used to parse a model file and generate Java and SQL
11
+ * output files.
12
+ *
13
+ ******************************************************************************/
14
+
15
+ public class Main {
16
+
17
+
18
+ //**************************************************************************
19
+ //** main
20
+ //**************************************************************************
21
+ /** Entry point for the application
22
+ * @param arguments Command line arguments
23
+ */
24
+ public static void main (String [] arguments ) throws Exception {
25
+ HashMap <String , String > args = console .parseArgs (arguments );
26
+
27
+
28
+ //Print version as needed
29
+ if (args .containsKey ("-version" )){
30
+ Jar jar = new Jar (Main .class );
31
+ javaxt .io .File jarFile = new javaxt .io .File (jar .getFile ());
32
+ String version = jar .getVersion ();
33
+ if (version ==null ) version = "Unknown" ;
34
+ System .out .println (jarFile .getName (false ) + " version \" " + version + "\" " );
35
+ return ;
36
+ }
37
+
38
+
39
+ //Parse inputs
40
+ String input = args .get ("-input" );
41
+ String output = args .get ("-output" );
42
+ if (input ==null ){
43
+ if (arguments .length >0 ) input = arguments [0 ];
44
+ if (arguments .length >1 ) output = arguments [1 ];
45
+ }
46
+
47
+
48
+ //Get input file
49
+ javaxt .io .File inputFile ;
50
+ try {
51
+ if (input ==null ) throw new IllegalArgumentException ("Input file is required" );
52
+ inputFile = new javaxt .io .File (input );
53
+ if (!inputFile .exists ()) throw new IllegalArgumentException ("Input file not found" );
54
+ }
55
+ catch (Exception e ){
56
+ System .out .println (e .getMessage ());
57
+ return ;
58
+ }
59
+
60
+
61
+ //Get output directory
62
+ javaxt .io .Directory outputDirectory = output ==null ?
63
+ inputFile .getDirectory () : new javaxt .io .Directory (output );
64
+
65
+
66
+ //Create models
67
+ Model [] models = new Parser (inputFile .getText ()).getModels ();
68
+
69
+
70
+ //Create files
71
+ Writer .write (models , outputDirectory );
72
+ }
59
73
}
0 commit comments