nsISupports
Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)Components may implement the nsICommandLineHandler
interface to add custom command line handling behavior.
long findFlag(in AString aFlag, in boolean aCaseSensitive); |
AString getArgument(in long aIndex); |
boolean handleFlag(in AString aFlag, in boolean aCaseSensitive); |
AString handleFlagWithParam(in AString aFlag, in boolean aCaseSensitive); |
void removeArguments(in long aStart, in long aEnd); |
nsIFile resolveFile(in AString aArgument); |
nsIURI resolveURI(in AString aArgument); |
Attribute | Type | Description |
length | long | Number of arguments in the command line. The application name is not part of the command line. Read only. |
preventDefault | boolean | There may be a command-line handler which performs a default action if there was no explicit action on the command line (open a default browser window, for example). This flag allows the default action to be prevented. |
state | unsigned long | The type of command line being processed. See State constants. Read only. |
windowContext |
| A window to be targeted by this command line. In most cases, this will be null (xremote will sometimes set this attribute). Read only. |
workingDirectory |
| The working directory for this command line. Use this property instead of the working directory for the current process, since a redirected command line may have had a different working directory. Read only. |
Constant | Value | Description |
STATE_INITIAL_LAUNCH | 0 | The first launch of the application instance. |
STATE_REMOTE_AUTO | 1 | A remote command line automatically redirected to this instance. |
STATE_REMOTE_EXPLICIT | 2 | A remote command line explicitly redirected to this instance using xremote/windde/appleevents. |
Finds a command-line flag, returning its position on the command line.
long findFlag( in AString aFlag, in boolean aCaseSensitive );
aFlag
aCaseSensitive
The position of the flag in the command line, or -1 if the flag is not found.
Gets the value an argument from the array of command-line arguments, given the index into the argument list.
On Windows, flags of the form /flag
are normalized to -flag
. /flag:param
are normalized to -flag param
.
On Unix/Linux and Mac OS X, flags of the form --flag
are normalized to -flag
, and flags of the form --flag=param
are normalized to the form -flag param
.
AString getArgument( in long aIndex );
aIndex
The value of the specified argument. This is the full text of that argument, so if the argument is a flag, the returned value is "-flag [<flagvalue>]
".
NS_ERROR_INVALID_ARG
Finds the specified flag, removing it from the array of flags. Reports whether or not the specified flag was found. This is useful for Boolean flags; that is, flags that don't accept a parameter. You can determine if the flag was provided and remove it from the list of flags waiting to be processed in one operation.
boolean handleFlag( in AString aFlag, in boolean aCaseSensitive );
aFlag
aCaseSensitive
true
if the flag was found, otherwise false
.
Finds a flag in the list of flags waiting to be processed and returns its value, after removing both the flag and its value from the list of flags waiting to be handled. This is useful for processing flags that accept a value. This is, essentially, a helper method that combines findFlag()
and removeArguments()
into one operation.
AString handleFlagWithParam( in AString aFlag, in boolean aCaseSensitive );
aFlag
aCaseSensitive
The value of the specified flag, an empty string if the flag's value is the empty string, or null
if the specified parameter wasn't found.
NS_ERROR_INVALID_ARG
Removes a range of arguments from the command line; this is typically done once those arguments have been handled.
void removeArguments( in long aStart, in long aEnd );
aStart
aEnd
Resolves a file-path argument into an nsIFile
object. This method gracefully handles relative or absolute file paths, according to the working directory of this command line.
nsIFile resolveFile( in AString aArgument );
aArgument
The file path as an nsIFile
.
Resolves a URI argument into a URI. This method has platform-specific logic for converting an absolute URI or a relative file-path into the appropriate URI object; it gracefully handles win32 C:\ paths which would confuse the I/O service if passed directly.
nsIURI resolveURI( in AString aArgument );
aArgument
A platform-specific URI.