Fix bug 274311: Can you add all of the shell commands to the help() menu?

Patch from Roshan James <roshanj@google.com>.
This commit is contained in:
nboyd%atg.com 2007-06-04 13:46:58 +00:00
Родитель dc21b18581
Коммит fc308affdb
3 изменённых файлов: 46 добавлений и 18 удалений

Просмотреть файл

@ -53,16 +53,18 @@ msg.no-opt =\
to compile to class files. to compile to class files.
msg.shell.usage =\ msg.shell.usage =\
Didn''t understand "{0}". \n\ Usage: java {0} [options...] [files]\n\
Valid arguments are:\n\ Valid options are:\n\
\ -w\n\ \ -?, -help Displays help messages.\n\
\ -w Enable warnings.\n\
\ -version 100|110|120|130|140|150|160\n\ \ -version 100|110|120|130|140|150|160\n\
\ -opt [-1|0-9]\n\ \ Set a specific language version.\n\
\ -f script-filename\n\ \ -opt [-1|0-9] Set optimization level.\n\
\ -e script-source\n\ \ -f script-filename Execute script file.\n\
\ -debug\n\ \ -e script-source Evaluate inline script.\n\
\ -strict\n\ \ -debug Generate debug code.\n\
\ -fatal-warnings \ -strict Enable strict mode warnings.\n\
\ -fatal-warnings Treat warnings as errors.
msg.help =\ msg.help =\
@ -81,11 +83,28 @@ msg.help =\
print([expr ...]) Evaluate and print expressions. \n\ print([expr ...]) Evaluate and print expressions. \n\
quit() Quit the shell. \n\ quit() Quit the shell. \n\
version([number]) Get or set the JavaScript version number. \n\ version([number]) Get or set the JavaScript version number. \n\
gc() Runs the garbage collector.\n\
spawn(arg) Evaluate function or scriptname on a new thread \n\
sync(function) Creates a synchronized version of the function, \n\
\ where the synchronization object is "this" \n\
readFile(fileName [, encoding])\n\
\ Returns the content of the file as a string. \n\
\ Encoding of the string can be optionally specified. \n\
readUrl(url [, encoding]) \n\
\ Similar to readFile, reads the contents of the url.\n\
runCommand(name ...) Runs a specified shell command. Additional arguments are \n\
\ passed to the command \n\
seal(args ...) Seals the supplied objects \n\
toint32(arg) Converts the argument into a 32-bit integer \n\
serialize(obj, fileName) \n\
\ Serializes an object and saves it to a file \n\
deserialise(fileName) Reconstructs a serialized object \n\
environment Returns the current environment object \n\
history Displays the shell command history \n\
\n\ \n\
For full description of all available commands see shell.html in\n\ For full description of all available commands see shell.html in\n\
the docs directory of Rhino distribution.\n\ the docs directory of Rhino distribution.\n\
msg.warning =\ msg.warning =\
warning: {0} warning: {0}
@ -118,16 +137,16 @@ Valid options are: \n\
\ -debug, -g Include debug information.\n\ \ -debug, -g Include debug information.\n\
\ -nosource Do not include source to function objects.\n\ \ -nosource Do not include source to function objects.\n\
\ It makes f.toString() useless and violates ECMAScript\n\ \ It makes f.toString() useless and violates ECMAScript\n\
\ standard but makes generated classes smaller and\n\ \ standard but makes generated classes smaller and\n\
\ saves memory.\n\ \ saves memory.\n\
\ -o CLASSNAME Use specified name as the last component of the main\n\ \ -o CLASSNAME Use specified name as the last component of the main\n\
\ generated class name. When specified, only one script\n\ \ generated class name. When specified, only one script\n\
\ SOURCE is allowed. If omitted, it defaults to source\n\ \ SOURCE is allowed. If omitted, it defaults to source\n\
\ name with stripped .js suffix.\n\ \ name with stripped .js suffix.\n\
\ -package PACKAHGE Place generated classes in the specified package.\n\ \ -package PACKAHGE Place generated classes in the specified package.\n\
\ -d DIRECTORY Use DIRECTORY as destination directory for generated\n\ \ -d DIRECTORY Use DIRECTORY as destination directory for generated\n\
\ classes. If omitted, it defaults to parent directory\n\ \ classes. If omitted, it defaults to parent directory\n\
\ of SOURCE.\n\ \ of SOURCE.\n\
\ -extends CLASS The main generated class will extend the specified\n\ \ -extends CLASS The main generated class will extend the specified\n\
\ class CLASS.\n\ \ class CLASS.\n\
\ -implements INTERFACE1,INTERFACE2,... The main generated class will\n\ \ -implements INTERFACE1,INTERFACE2,... The main generated class will\n\

Просмотреть файл

@ -571,7 +571,7 @@ public class Global extends ImporterTopLevel
} }
/** /**
* The readFile reads the given file context and convert it to a string * The readFile reads the given file content and convert it to a string
* using the specified character coding or default character coding if * using the specified character coding or default character coding if
* explicit coding argument is not given. * explicit coding argument is not given.
* <p> * <p>

Просмотреть файл

@ -289,12 +289,21 @@ public class Main
shellContextFactory.setGeneratingDebug(true); shellContextFactory.setGeneratingDebug(true);
continue; continue;
} }
if (arg.equals("-?") ||
arg.equals("-help")) {
// print usage message
global.getOut().println(
ToolErrorReporter.getMessage("msg.shell.usage", Main.class.getName()));
System.exit(1);
}
usageError = arg; usageError = arg;
break goodUsage; break goodUsage;
} }
// print usage message // print error and usage message
global.getOut().println( global.getOut().println(
ToolErrorReporter.getMessage("msg.shell.usage", usageError)); ToolErrorReporter.getMessage("msg.shell.invalid", usageError));
global.getOut().println(
ToolErrorReporter.getMessage("msg.shell.usage", Main.class.getName()));
System.exit(1); System.exit(1);
return null; return null;
} }