From 014af474e4267a2ad99c33bf744a3a876da03fc2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 30 Jun 2013 11:27:33 +0200 Subject: add package for java version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/ArgParser.java | 1082 ----------------------------------------- src/Test.java | 1 + src/argparser/ArgParser.java | 1084 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1085 insertions(+), 1082 deletions(-) delete mode 100644 src/ArgParser.java create mode 100644 src/argparser/ArgParser.java diff --git a/src/ArgParser.java b/src/ArgParser.java deleted file mode 100644 index 6611b04..0000000 --- a/src/ArgParser.java +++ /dev/null @@ -1,1082 +0,0 @@ -/** - * argparser – command line argument parser library - * - * Copyright © 2013 Mattias Andrée (maandree@member.fsf.org) - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This library 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library. If not, see . - */ -import java.util.*; -import java.io.*; - - -/** - * Simple argument parser - * - * @author Mattias Andrée, maandree@member.fsf.org - */ -public class ArgParser -{ - /** - *

Constructor

- *

- * The short description is printed on same line as the program name - *

- * - * @param description Short, single-line, description of the program - * @param usage Formated, multi-line, usage text, may be {@code null} - */ - public ArgParser(final String description, final String usage) - { this(description, usage, null, null, false); - } - - /** - *

Constructor

- *

- * The short description is printed on same line as the program name - *

- * - * @param description Short, single-line, description of the program - * @param usage Formated, multi-line, usage text, may be {@code null} - * @param useStderr Whether to use stderr instead of stdout - */ - public ArgParser(final String description, final String usage, final boolean useStderr) - { this(description, usage, null, null, useStderr); - } - - /** - *

Constructor

- *

- * The short description is printed on same line as the program name - *

- * - * @param description Short, single-line, description of the program - * @param usage Formated, multi-line, usage text, may be {@code null} - * @param longDescription Long, multi-line, description of the program, may be {@code null} - */ - public ArgParser(final String description, final String usage, final String longDescription) - { this(description, usage, longDescription, null, false); - } - - /** - *

Constructor

- *

- * The short description is printed on same line as the program name - *

- * - * @param description Short, single-line, description of the program - * @param usage Formated, multi-line, usage text, may be {@code null} - * @param longDescription Long, multi-line, description of the program, may be {@code null} - * @param useStderr Whether to use stderr instead of stdout - */ - public ArgParser(final String description, final String usage, final String longDescription, final boolean useStderr) - { this(description, usage, longDescription, null, useStderr); - } - - /** - *

Constructor

- *

- * The short description is printed on same line as the program name - *

- * - * @param description Short, single-line, description of the program - * @param usage Formated, multi-line, usage text, may be {@code null} - * @param longDescription Long, multi-line, description of the program, may be {@code null} - * @param program The name of the program, {@code null} for automatic - */ - public ArgParser(final String description, final String usage, final String longDescription, final String program) - { this(description, usage, longDescription, program, false); - } - - /** - *

Constructor

- *

- * The short description is printed on same line as the program name - *

- * - * @param description Short, single-line, description of the program - * @param usage Formated, multi-line, usage text, may be {@code null} - * @param longDescription Long, multi-line, description of the program, may be {@code null} - * @param program The name of the program, {@code null} for automatic - * @param useStderr Whether to use stderr instead of stdout - */ - public ArgParser(final String description, final String usage, final String longDescription, final String program, final boolean useStderr) - { - this.linuxvt = System.getenv("TERM") == null ? false : System.getenv("TERM").equals("linux"); - String prog = program == null ? ArgParser.parentName(0, true) : program; - this.program = prog == null ? "?" : prog; - this.description = description; - this.usage = usage; - this.longDescription = longDescription; - this.out = useStderr ? System.err : System.out; - } - - - - /** - * Whether the Linux VT is being used - */ - public boolean linuxvt; - - /** - * The name of the executed command - */ - public final String program; - - /** - * Short, single-line, description of the program - */ - private final String description; - - /** - * Formated, multi-line, usage text, {@code null} if none - */ - private final String usage; - - /** - * Long, multi-line, description of the program, {@code null} if none - */ - private final String longDescription; - - /** - * The error output stream - */ - private final OutputStream out; - - /** - * The passed arguments - */ - public String[] arguments = null; - - /** - * The number of unrecognised arguments - */ - public int unrecognisedCount = 0; - - /** - * The concatination of {@link #files} with blankspaces as delimiters, {@code null} if no files - */ - public String message = null; - - /** - * Options, in order - */ - private final ArrayList