MATSIM
CreateFullConfig.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * *
4  * *********************************************************************** *
5  * *
6  * copyright : (C) 2014 by the members listed in the COPYING, *
7  * LICENSE and WARRANTY file. *
8  * email : info at matsim dot org *
9  * *
10  * *********************************************************************** *
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * See also COPYING, LICENSE and WARRANTY file *
17  * *
18  * *********************************************************************** */
19 
20 package org.matsim.run;
21 
22 import java.util.Iterator;
23 
24 import org.matsim.core.config.Config;
28 
43 public class CreateFullConfig {
44 
45  private static String configFilename = null;
46 
47  public static void main(String[] args) {
48  parseArguments(args);
49 
50  Config config = ConfigUtils.createConfig();
51  new ConfigWriter(config).write(configFilename);
52  }
53 
54  private static void parseArguments(final String[] args) {
55  if (args.length == 0) {
56  System.out.println("Too few arguments.");
57  printUsage();
58  System.exit(1);
59  }
60  Iterator<String> argIter = new ArgumentParser(args).iterator();
61  String arg = argIter.next();
62  if (arg.equals("-h") || arg.equals("--help")) {
63  printUsage();
64  System.exit(0);
65  } else {
66  configFilename = arg;
67  if (argIter.hasNext()) {
68  System.out.println("Too many arguments.");
69  printUsage();
70  System.exit(1);
71  }
72  }
73  }
74 
75  private static void printUsage() {
76  System.out.println();
77  System.out.println("CreateFullConfig");
78  System.out.println();
79  System.out.println("Writes a new configuration file with all known parameters and their default");
80  System.out.println("values.");
81  System.out.println();
82  System.out.println("usage: CreateFullConfig path/to/config.xml");
83  System.out.println();
84  System.out.println("Options:");
85  System.out.println("-h, --help: Displays this message.");
86  System.out.println();
87  System.out.println("----------------");
88  System.out.println("2014, matsim.org");
89  System.out.println();
90  }
91 }
static void parseArguments(final String[] args)
final void write(final String filename)
static void main(String[] args)
static Config createConfig(final String context)