@@ -16,65 +16,71 @@ import io.vertx.ext.web.client.WebClientOptions
1616import java.io.File
1717
1818
19+ private val CHUNK_SIZE = " chunkSize"
1920
2021fun main (args : Array <String >) {
2122
2223 val cli = CLI .create(" crawler" )
2324 .setSummary(" A REST Client to query all model element from server." )
24- .addArgument(Argument ()
25- .setArgName(" username" )
26- .setIndex(0 )
27- .setDefaultValue(" admin" )
28- .setDescription(" TWC username." )
29- )
30- .addArgument(Argument ()
31- .setArgName(" password" )
32- .setIndex(1 )
33- .setDefaultValue(" admin" )
34- .setDescription(" TWC password." )
35- )
36- .addOption(Option ()
37- .setLongName(" help" )
38- .setShortName(" h" )
39- .setDescription(" Show help site." )
40- .setFlag(true )
41- )
42- .addOption(Option ()
43- .setLongName(" server" )
44- .setShortName(" S" )
45- .setDescription(" Set server path." )
46- )
47- .addOption(Option ()
48- .setLongName(" port" )
49- .setShortName(" P" )
50- .setDescription(" Set server port number." )
51- )
52- .addOption(Option ()
53- .setLongName(" instanceNum" )
54- .setShortName(" I" )
55- .setDescription(" Set number of RESTVerticle instances. Default:16" )
56- .setDefaultValue(" 16" )
57- )
58- .addOption(Option ()
59- .setLongName(" workspaceId" )
60- .setShortName(" W" )
61- .setDescription(" Select workspace to crawl" )
62- )
63- .addOption(Option ()
64- .setLongName(" resourceId" )
65- .setShortName(" R" )
66- .setDescription(" Select resource to crawl" )
67- )
68- .addOption(Option ()
69- .setLongName(" branchId" )
70- .setShortName(" B" )
71- .setDescription(" Select branch to crawl" )
72- )
73- .addOption(Option ()
74- .setLongName(" revision" )
75- .setShortName(" REV" )
76- .setDescription(" Select revision to crawl" )
77- )
25+ .addArguments(listOf (
26+ Argument ()
27+ .setArgName(" username" )
28+ .setIndex(0 )
29+ .setDefaultValue(" admin" )
30+ .setDescription(" TWC username." ),
31+ Argument ()
32+ .setArgName(" password" )
33+ .setIndex(1 )
34+ .setDefaultValue(" admin" )
35+ .setDescription(" TWC password." )
36+ ))
37+ .addOptions(listOf (
38+ Option ()
39+ .setLongName(" help" )
40+ .setShortName(" h" )
41+ .setDescription(" Show help site." )
42+ .setFlag(true ),
43+ Option ()
44+ .setLongName(" server" )
45+ .setShortName(" S" )
46+ .setDescription(" Set server path." ),
47+ Option ()
48+ .setLongName(" port" )
49+ .setShortName(" P" )
50+ .setDescription(" Set server port number." ),
51+ Option ()
52+ .setLongName(" instanceNum" )
53+ .setShortName(" I" )
54+ .setDescription(" Set number of RESTVerticle instances. Default:16" )
55+ .setDefaultValue(" 16" ),
56+ Option ()
57+ .setLongName(" workspaceId" )
58+ .setShortName(" W" )
59+ .setDescription(" Select workspace to crawl" ),
60+ Option ()
61+ .setLongName(" resourceId" )
62+ .setShortName(" R" )
63+ .setDescription(" Select resource to crawl" ),
64+ Option ()
65+ .setLongName(" branchId" )
66+ .setShortName(" B" )
67+ .setDescription(" Select branch to crawl" ),
68+ Option ()
69+ .setLongName(" revision" )
70+ .setShortName(" REV" )
71+ .setDescription(" Select revision to crawl" ),
72+ Option ()
73+ .setLongName(" debug" )
74+ .setShortName(" D" )
75+ .setDescription(" Set number of RESTVerticle instances. Default:16" )
76+ .setFlag(true ),
77+ Option ()
78+ .setLongName(CHUNK_SIZE )
79+ .setShortName(" C" )
80+ .setDescription(" Set the size of chunks to use when crawling elements. Default -1 to disable chunks" )
81+ .setDefaultValue(" -1" )
82+ ))
83+
7884
7985
8086 val commandLine = cli.parse(args.asList(),false )
@@ -97,6 +103,15 @@ fun main(args: Array<String>) {
97103 val resourceId = commandLine.getOptionValue<String >(" resourceId" )
98104 val branchId = commandLine.getOptionValue<String >(" branchId" )
99105 val revision = commandLine.getOptionValue<String >(" revision" )
106+ val chunkSize = commandLine.getOptionValue<String >(CHUNK_SIZE ).toInt()
107+ val debug = commandLine.isFlagEnabled(" debug" )
108+
109+ twcMap.put(" debug" , debug)
110+ if (debug) {
111+ println (" Debug mode is enabled" )
112+ }
113+ println (" Chunk size is $chunkSize " )
114+ twcMap.put(CHUNK_SIZE , chunkSize)
100115
101116 if (instanceNum!= null ){
102117 println (" Instance number set to $instanceNum " )
@@ -121,6 +136,7 @@ fun main(args: Array<String>) {
121136 twcMap.put(DataConstants .REVISION , revision.toInt())
122137 }
123138
139+
124140 if (serverOpt != null && portOpt!= null ){
125141 if (! File (" server.config" ).exists()){
126142 File (" server.config" ).createNewFile()
0 commit comments