Interface nsICommandLineRunnerType

Extension of nsICommandLine that allows for initialization of new command lines and running the command line actions by processing the command line handlers.

Status

INTERNAL - This interface is not meant for use by embedders, and is not intended to be frozen. If you are an embedder and need functionality provided by this interface, talk to Benjamin Smedberg benjamin@smedbergs.us.

Hierarchy

Properties

helpText: string

Process and combine the help text provided by each command-line handler.

length: number

Number of arguments in the command line. The application name is not part of the command line.

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: number

The type of command line being processed.

STATE_INITIAL_LAUNCH is the first launch of the application instance. STATE_REMOTE_AUTO is a remote command line automatically redirected to this instance. STATE_REMOTE_EXPLICIT is a remote command line explicitly redirected to this instance using xremote/windde/appleevents.

workingDirectory: nsIFile

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.

Throws

NS_ERROR_NOT_INITIALIZED if the working directory was not specified.

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • Find a command-line flag.

    Returns

    The position of the flag in the command line.

    Parameters

    • aFlag: string

      The flag name to locate. Do not include the initial hyphen.

    • aCaseSensitive: boolean

      Whether to do case-sensitive comparisons.

    Returns number

  • Get an argument from the array of command-line arguments.

    On windows, flags of the form /flag are normalized to -flag. /flag:param are normalized to -flag param.

    On *nix and mac flags of the form --flag are normalized to -flag. --flag=param are normalized to the form -flag param.

    Returns

    The indexth argument.

    Throws

    NS_ERROR_ILLEGAL_VALUE if aIndex is out of bounds.

    Parameters

    • aIndex: number

      The argument to retrieve. This index is 0-based, and does not include the application name.

    Returns string

  • A helper method which will find a flag and remove it in one step.

    Returns

    Whether the flag was found.

    Parameters

    • aFlag: string

      The flag name to find and remove.

    • aCaseSensitive: boolean

      Whether to do case-sensitive comparisons.

    Returns boolean

  • Find a flag with a parameter and remove both. This is a helper method that combines "findFlag" and "removeArguments" in one step.

    Returns

    null (a void astring) if the flag is not found. The parameter value if found. Note that null and the empty string are not the same.

    Throws

    NS_ERROR_INVALID_ARG if the flag exists without a parameter

    Parameters

    • aFlag: string

      The flag name to find and remove.

    • aCaseSensitive: boolean

      Whether to do case-sensitive flag search.

    Returns string

  • This method assumes a native character set, and is meant to be called with the argc/argv passed to main(). Talk to bsmedberg if you need to create a command line using other data. argv will not be altered in any way.

    On Windows, the "native" character set is UTF-8, not the native codepage.

    Parameters

    • argc: number
    • argv: nsArgvArray
    • workingDir: nsIFile

      The working directory for resolving file and URI paths. Can be null, in which case resolving files will not work, and only absolute URIs will be resolvable.

    • state: number

      The nsICommandLine.state flag.

    Returns void

  • Remove arguments from the command line. This normally occurs after a handler has processed the arguments.

    Parameters

    • aStart: number

      Index to begin removing.

    • aEnd: number

      Index to end removing, inclusive.

    Returns void

  • Resolve a file-path argument into an nsIFile. This method gracefully handles relative or absolute file paths, according to the working directory of this command line. If the path is relative and there is no working directory available, this may return null.

    Parameters

    • aArgument: string

      The path to resolve.

    Returns 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 ioservice if passed directly.

    Parameters

    • aArgument: string

      The command-line argument to resolve.

    Returns nsIURI

  • Process the command-line handlers in the proper order, calling "handle()" on each.

    Throws

    NS_ERROR_ABORT if any handler throws NS_ERROR_ABORT. All other errors thrown by handlers will be silently ignored.

    Returns void

Generated using TypeDoc