Java tutorial
// Copyright 2015 Sebastian Kuerten // // This file is part of osm4j. // // osm4j is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // osm4j is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with osm4j. If not, see <http://www.gnu.org/licenses/>. package de.topobyte.osm4j.utils; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; public abstract class AbstractExecutable { protected abstract String getHelpMessage(); protected Options options = new Options(); protected CommandLine line = null; protected void setup(String[] args) { try { line = new DefaultParser().parse(options, args); } catch (ParseException e) { System.out.println("unable to parse command line: " + e.getMessage()); new HelpFormatter().printHelp(getHelpMessage(), options); System.exit(1); } } }