0a0941e0a71733d0301744b9cbe49ee3136ea2d3
[rhynodge.git] / src / main / java / net / pterodactylus / reactor / engine / Starter.java
1 /*
2  * Reactor - Starter.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.reactor.engine;
19
20 import net.pterodactylus.reactor.loader.ChainWatcher;
21 import net.pterodactylus.reactor.states.StateManager;
22
23 import com.lexicalscope.jewel.cli.CliFactory;
24 import com.lexicalscope.jewel.cli.Option;
25
26 /**
27  * Reactor main starter class.
28  *
29  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
30  */
31 public class Starter {
32
33         /**
34          * JVM main entry method.
35          *
36          * @param arguments
37          *            Command-line arguments
38          */
39         public static void main(String... arguments) {
40
41                 /* parse command line. */
42                 Parameters parameters = CliFactory.parseArguments(Parameters.class, arguments);
43
44                 /* create the state manager. */
45                 StateManager stateManager = new StateManager(parameters.getStateDirectory());
46
47                 /* create the engine. */
48                 Engine engine = new Engine(stateManager);
49
50                 /* start a watcher. */
51                 ChainWatcher chainWatcher = new ChainWatcher(engine, parameters.getChainDirectory());
52                 chainWatcher.start();
53
54                 /* start the engine. */
55                 engine.start();
56         }
57
58         /**
59          * Definition of the command-line parameters.
60          *
61          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
62          */
63         private static interface Parameters {
64
65                 /**
66                  * Returns the directory to watch for chains.
67                  *
68                  * @return The chain directory
69                  */
70                 @Option(defaultValue = "chains", shortName = "c", description = "The directory to watch for chains")
71                 String getChainDirectory();
72
73                 /**
74                  * Returns the directory to store states in.
75                  *
76                  * @return The states directory
77                  */
78                 @Option(defaultValue = "states", shortName = "s", description = "The directory to store states in")
79                 String getStateDirectory();
80
81         }
82
83 }