Class CommandLine

Introduction

This class provides several useful methods for parsing the command line.

Contents

  1. Introduction
  2. Contents
  3. Explanation of symbols used
  4. Member reference
    1. Args - list of all arguments
    2. HasSwitch - test for command-line switch
    3. SwitchArgs - return the parameters for a switch
    4. SwitchPrefix - prefix for switches
    5. Text - full text of the command line

Explanation of symbols used

Words in italics indicate an instance of a class. The word corresponds to the class name, except where more than one instance is represented in the same statement. In that case a number (2, 3, etc.) is appended to the class name.

Words in normal typeface are to be taken literally (required punctuation, class name in a static reference, method name, etc.)

The symbol => is used to separate an expression (on the left) from its return value (on the right).

An ellipsis (...) indicates that the previous argument may be repeated any number of times. The description will indicate whether one instance is required.

Member reference

static property Args

CommandLine.Args => ls
This static property yields a list of all whitespace-delimited arguments on the command line, not including dbr/dbs, the program name, or any of the runtime switches that occur between them. If quoted strings are encountered, they are returned as a single argument, without the quotes. This list of arguments will include any switches that follow the program name.

static method HasSwitch

CommandLine.HasSwitch(a) => boolean
This static method tests the command line arguments for the existence of a switch specified by a, and returns true if found, otherwise false. Do not include the switch prefix in a, it will be added. Switch names are case-sensitive and may not be abbreviated.

static method SwitchArgs

CommandLine.SwitchArgs(a) => ls
This static method returns the arguments that follow the switch specified by a up to the next switch. Do not include the switch prefix in a, it will be added. Switch parameters must follow their switch, delimited by spaces. If the same switch occurs more than once, all parameters from all occurrences will be collected. If the switch does not occur, or has no arguments, then ls will be returned as an empty list.

static SwitchPrefix

CommandLine.SwitchPrefix => a
CommandLine.SwitchPrefix = a
The static member holds the character used to prefix switches in the command line. If not set, it will be set on first use to '-' unless Synergy/DE option 34 is enabled, in which case it will be set to '/'. You may set this to any single character.

static property Text

CommandLine.Text => a
Returns the full text of the command line for the current process.