Skip to content

Commit c96f364

Browse files
committed
improve help about options that do nothing and support giving short options together
1 parent 7960c70 commit c96f364

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ protected List<String> preprocessArguments(List<String> givenArgs, Map<String, S
9090
String arg = arguments.get(i);
9191
switch (arg) {
9292
case "-B":
93-
System.out.println("Warning: " + arg + " does nothing on GraalPython.");
9493
break;
9594
case "-c":
9695
i += 1;
@@ -123,7 +122,7 @@ protected List<String> preprocessArguments(List<String> givenArgs, Map<String, S
123122
break;
124123
case "-O":
125124
case "-OO":
126-
System.out.println("Warning: " + arg + " does nothing on GraalPython.");
125+
case "-R":
127126
break;
128127
case "-q":
129128
quietFlag = true;
@@ -192,7 +191,13 @@ protected List<String> preprocessArguments(List<String> givenArgs, Map<String, S
192191
inputFile = arg;
193192
programArgs.add(inputFile);
194193
break;
194+
} else if (!arg.startsWith("--") && arg.length() > 2) {
195+
// short arguments can be given together
196+
for (String optionChar : arg.substring(1).split("")) {
197+
arguments.add(i + 1, "-" + optionChar);
198+
}
195199
} else {
200+
// possibly a polyglot argument
196201
unrecognized.add(arg);
197202
}
198203
}
@@ -494,20 +499,23 @@ protected String getLanguageId() {
494499
protected void printHelp(OptionCategory maxCategory) {
495500
print("usage: python [option] ... (-c cmd | file) [arg] ...\n" +
496501
"Options and arguments (and corresponding environment variables):\n" +
497-
"-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n" +
502+
"-B : on CPython, this disables writing .py[co] files on import;\n" +
503+
" GraalPython does not use bytecode, and thus this flag has no effect\n" +
498504
"-c cmd : program passed in as string (terminates option list)\n" +
499505
// "-d : debug output from parser; also PYTHONDEBUG=x\n" +
500506
"-E : ignore PYTHON* environment variables (such as PYTHONPATH)\n" +
501507
"-h : print this help message and exit (also --help)\n" +
502508
"-i : inspect interactively after running script; forces a prompt even\n" +
503509
" if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n" +
504510
"-m mod : run library module as a script (terminates option list)\n" +
505-
"-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n" +
506-
"-OO : remove doc-strings in addition to the -O optimizations\n" +
507-
// "-R : use a pseudo-random salt to make hash() values of various types
508-
// be\n" +
509-
// " unpredictable between separate invocations of the interpreter, as\n" +
510-
// " a defense against denial-of-service attacks\n" +
511+
"-O : on CPython, this optimizes generated bytecode slightly;\n" +
512+
" GraalPython does not use bytecode, and thus this flag has no effect\n" +
513+
"-OO : remove doc-strings in addition to the -O optimizations;\n" +
514+
" GraalPython does not use bytecode, and thus this flag has no effect\n" +
515+
"-R : on CPython, this enables the use of a pseudo-random salt to make\n"+
516+
" hash()values of various types be unpredictable between separate\n" +
517+
" invocations of the interpreter, as a defense against denial-of-service\n" +
518+
" attacks; GraalPython always enables this and the flag has no effect.\n" +
511519
// "-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n"
512520
// +
513521
"-q : don't print version and copyright messages on interactive startup\n" +

0 commit comments

Comments
 (0)