< prev index next >

src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java

Print this page
rev 48495 : 8189102: All tools should support -?, -h and --help
Reviewed-by: kvn, jjg, weijun, alanb, rfield, ksrini
   1 /*
   2  * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 498             }
 499             if (options.has(argQuiet)) {
 500                 quiet = true;
 501             }
 502             return super.parse(options);
 503         }
 504     }
 505 
 506     // option parsing for command-line
 507     private class OptionParserCommandLine extends OptionParserBase {
 508 
 509         private final OptionSpec<String> argStart = parser.accepts("startup").withRequiredArg();
 510         private final OptionSpecBuilder argNoStart = parser.acceptsAll(asList("n", "no-startup"));
 511         private final OptionSpec<String> argFeedback = parser.accepts("feedback").withRequiredArg();
 512         private final OptionSpec<String> argExecution = parser.accepts("execution").withRequiredArg();
 513         private final OptionSpecBuilder argQ = parser.accepts("q");
 514         private final OptionSpecBuilder argS = parser.accepts("s");
 515         private final OptionSpecBuilder argV = parser.accepts("v");
 516         private final OptionSpec<String> argR = parser.accepts("R").withRequiredArg();
 517         private final OptionSpec<String> argC = parser.accepts("C").withRequiredArg();
 518         private final OptionSpecBuilder argHelp = parser.acceptsAll(asList("h", "help"));
 519         private final OptionSpecBuilder argVersion = parser.accepts("version");
 520         private final OptionSpecBuilder argFullVersion = parser.accepts("full-version");
 521         private final OptionSpecBuilder argShowVersion = parser.accepts("show-version");
 522         private final OptionSpecBuilder argHelpExtra = parser.acceptsAll(asList("X", "help-extra"));
 523 
 524         private String feedbackMode = null;
 525         private Startup initialStartup = null;
 526 
 527         String feedbackMode() {
 528             return feedbackMode;
 529         }
 530 
 531         Startup startup() {
 532             return initialStartup;
 533         }
 534 
 535         @Override
 536         void msg(String key, Object... args) {
 537             errormsg(key, args);
 538         }


   1 /*
   2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 498             }
 499             if (options.has(argQuiet)) {
 500                 quiet = true;
 501             }
 502             return super.parse(options);
 503         }
 504     }
 505 
 506     // option parsing for command-line
 507     private class OptionParserCommandLine extends OptionParserBase {
 508 
 509         private final OptionSpec<String> argStart = parser.accepts("startup").withRequiredArg();
 510         private final OptionSpecBuilder argNoStart = parser.acceptsAll(asList("n", "no-startup"));
 511         private final OptionSpec<String> argFeedback = parser.accepts("feedback").withRequiredArg();
 512         private final OptionSpec<String> argExecution = parser.accepts("execution").withRequiredArg();
 513         private final OptionSpecBuilder argQ = parser.accepts("q");
 514         private final OptionSpecBuilder argS = parser.accepts("s");
 515         private final OptionSpecBuilder argV = parser.accepts("v");
 516         private final OptionSpec<String> argR = parser.accepts("R").withRequiredArg();
 517         private final OptionSpec<String> argC = parser.accepts("C").withRequiredArg();
 518         private final OptionSpecBuilder argHelp = parser.acceptsAll(asList("?", "h", "help"));
 519         private final OptionSpecBuilder argVersion = parser.accepts("version");
 520         private final OptionSpecBuilder argFullVersion = parser.accepts("full-version");
 521         private final OptionSpecBuilder argShowVersion = parser.accepts("show-version");
 522         private final OptionSpecBuilder argHelpExtra = parser.acceptsAll(asList("X", "help-extra"));
 523 
 524         private String feedbackMode = null;
 525         private Startup initialStartup = null;
 526 
 527         String feedbackMode() {
 528             return feedbackMode;
 529         }
 530 
 531         Startup startup() {
 532             return initialStartup;
 533         }
 534 
 535         @Override
 536         void msg(String key, Object... args) {
 537             errormsg(key, args);
 538         }


< prev index next >