// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.gui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import java.util.stream.Stream;
import org.openstreetmap.josm.tools.Logging;
import org.openstreetmap.josm.tools.OptionParser;
import org.openstreetmap.josm.tools.OptionParser.OptionCount;
/**
* This class holds the arguments passed on to {@link MainApplication#main}.
* @author Michael Zangl
* @since 10899
*/
public class ProgramArguments {
/**
* JOSM command line options.
* @see Help/CommandLineOptions
*/
public enum Option {
/** --help|-h Show this help */
HELP(false),
/** --version Displays the JOSM version and exits */
VERSION(false),
/** --debug Print debugging messages to console */
DEBUG(false),
/** --trace Print detailed debugging messages to console */
TRACE(false),
/** --language=<language> Set the language */
LANGUAGE(true),
/** --reset-preferences Reset the preferences to default */
RESET_PREFERENCES(false),
/** --load-preferences=<url-to-xml> Changes preferences according to the XML file */
LOAD_PREFERENCES(true),
/** --set=<key>=<value> Set preference key to value */
SET(true),
/** --geometry=widthxheight(+|-)x(+|-)y Standard unix geometry argument */
GEOMETRY(true),
/** --no-maximize Do not launch in maximized mode */
NO_MAXIMIZE(false),
/** --maximize Launch in maximized mode */
MAXIMIZE(false),
/** --download=minlat,minlon,maxlat,maxlon Download the bounding box
* --download=<URL> Download the location at the URL (with lat=x&lon=y&zoom=z)
* --download=<filename> Open a file (any file type that can be opened with File/Open) */
DOWNLOAD(true),
/** --downloadgps=minlat,minlon,maxlat,maxlon Download the bounding box as raw GPS
* --downloadgps=<URL> Download the location at the URL (with lat=x&lon=y&zoom=z) as raw GPS */
DOWNLOADGPS(true),
/** --selection=<searchstring> Select with the given search */
SELECTION(true),
/** --offline=<OSM_API|JOSM_WEBSITE|CACHE_UPDATES|CERTIFICATES|ALL> Disable access to the given resource(s), delimited by comma */
OFFLINE(true),
/** --skip-plugins */
SKIP_PLUGINS(false);
private final String name;
private final boolean requiresArg;
Option(boolean requiresArgument) {
this.name = name().toLowerCase(Locale.ENGLISH).replace('_', '-');
this.requiresArg = requiresArgument;
}
/**
* Replies the option name
* @return The option name, in lowercase
*/
public String getName() {
return name;
}
/**
* Determines if this option requires an argument.
* @return {@code true} if this option requires an argument, {@code false} otherwise
*/
public boolean requiresArgument() {
return requiresArg;
}
}
private final Map