ArgvPattern

@alexeyp0708/argv_patterns. ArgvPattern

Class ArgvPattern create array containing [object ArgvElement] elements which are patterns

Constructor

new ArgvPattern()

Source:

Extends

Methods

(static) compareArgvToPatterns(argv, patterns, diff) → {ArgvArray}

Matches the argv parameters with the pattern, and returns the matches in [array ArgvArray].

Source:
See:
Parameters:
Name Type Description
argv string | Array | ArgvArray

Where string is the command line. Where Array- Argv array of command line parameters. Command line:

  • command1 command2
  • command "string from space" or command 'string from space'. Warn: quotes ( " and ') inside quotes are not recognized when parsing a string.
  • --option => option=true
  • --option=value or --option:value => option=value
  • --option value => option=value if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • --option --value or --option -v option option=--value or option=-v if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • -o option o=true
  • --o=value or -o:value => o=value
  • --o=value or -o:value => o=value
  • -o value => o=value if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • -o --value or -o -v => o=--value or o=-v if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
patterns string | Array | ArgvPattern

Where string is the command line. Where Array- Argv array of command line parameters. Command patterns:

  • command1 command2 command3 - the following command order must be present - command1 command2 command3.
  • command * * the following command order must be present - command any_string_without_spaces "any string"
  • command /hello|bay/i the following command order must be present - command hello or command bay, according to regular expressions. Option patterns:
  • --option => option=true
  • --option=value => option=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • -o => o=true
  • -o=value => o=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • -abc => a=true b=true c=true
  • -abc=value => a=true b=true c=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • [-o --option] or [--option -o] => option=true or short o=true
  • [-o --option value] or [--option value] or [-o value] => option=value or short o=value where 'value' solid_string | string from space | "string from space" | * | / regular_exr /
diff boolean | Array

If set to false, it will give an error if the parameter set by the template is missing. If set empty array, then the missing parameter will be added to this array.

Throws:

Error: Bad parameters - syntactically bad parameter or poorly constructed command line. Error: Throws an error if the parameter is set according to the pattern, but does not match the criteria of the pattern. Error: Throws an error if an extra parameter is passed. Throws an error if diff argument is false. Error: Throws an error if the parameter is required according to the pattern, but it is missing and the default value is not set in the pattern.

Returns:
Type:
ArgvArray

parameters that intersect with the pattern

(static) compareArgvToPatterns(argv, patterns, diff) → {ArgvArray}

Matches the argv parameters with the pattern, and returns the matches in [array ArgvArray].

Source:
See:
Parameters:
Name Type Description
argv string | Array | ArgvArray

Where string is the command line. Where Array- Argv array of command line parameters. Command line:

  • command1 command2
  • command "string from space" or command 'string from space'. Warn: quotes ( " and ') inside quotes are not recognized when parsing a string.
  • --option => option=true
  • --option=value or --option:value => option=value
  • --option value => option=value if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • --option --value or --option -v option option=--value or option=-v if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • -o option o=true
  • --o=value or -o:value => o=value
  • --o=value or -o:value => o=value
  • -o value => o=value if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • -o --value or -o -v => o=--value or o=-v if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
patterns string | Array | ArgvPattern

Where string is the command line. Where Array- Argv array of command line parameters. Command patterns:

  • command1 command2 command3 - the following command order must be present - command1 command2 command3.
  • command * * the following command order must be present - command any_string_without_spaces "any string"
  • command /hello|bay/i the following command order must be present - command hello or command bay, according to regular expressions. Option patterns:
  • --option => option=true
  • --option=value => option=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • -o => o=true
  • -o=value => o=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • -abc => a=true b=true c=true
  • -abc=value => a=true b=true c=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • [-o --option] or [--option -o] => option=true or short o=true
  • [-o --option value] or [--option value] or [-o value] => option=value or short o=value where 'value' solid_string | string from space | "string from space" | * | / regular_exr /
diff boolean | Array

If set to false, it will give an error if the parameter set by the template is missing. If set empty array, then the missing parameter will be added to this array.

Throws:

Error: Bad parameters - syntactically bad parameter or poorly constructed command line. Error: Throws an error if the parameter is set according to the pattern, but does not match the criteria of the pattern. Error: Throws an error if an extra parameter is passed. Throws an error if diff argument is false. Error: Throws an error if the parameter is required according to the pattern, but it is missing and the default value is not set in the pattern.

Returns:
Type:
ArgvArray

parameters that intersect with the pattern

(static) elementsToPattern(argv) → {string}

Converting [object ArgvElement] elements from [array ArgvArray] to command line pattern

Source:
See:
Parameters:
Name Type Description
argv ArgvArray
Throws:

Error: Bad argument - Invalid argument

Returns:
Type:
string

Returns the assembled pattern

(static) elementsToPattern(argv) → {string}

Converting [object ArgvElement] elements from [array ArgvArray] to command line pattern

Source:
See:
Parameters:
Name Type Description
argv ArgvArray
Throws:

Error: Bad argument - Invalid argument

Returns:
Type:
string

Returns the assembled pattern

(static) getHelp(argv, pattern, descriptions) → {string}

Source:
Parameters:
Name Type Description
argv
pattern
descriptions object

{ '-':'this desc', }

Returns:
Type:
string

(static) getHelp(argv, pattern, descriptions) → {string}

Source:
Parameters:
Name Type Description
argv
pattern
descriptions object

{ '-':'this desc', }

Returns:
Type:
string

compare(argv, diff) → {ArgvArray}

Matches the argv parameters with the pattern, and returns the matches in [array ArgvArray]. See [method Argv.compareArgvToPatterns].

Source:
Parameters:
Name Type Description
argv string | Array | ArgvArray

argv parameters

diff

If set to false, it will give an error if the parameter set by the template is missing. If set empty array, then the missing parameter will be added to this array.

Returns:
Type:
ArgvArray

compare(argv, diff) → {ArgvArray}

Matches the argv parameters with the pattern, and returns the matches in [array ArgvArray]. See [method Argv.compareArgvToPatterns].

Source:
Parameters:
Name Type Description
argv string | Array | ArgvArray

argv parameters

diff

If set to false, it will give an error if the parameter set by the template is missing. If set empty array, then the missing parameter will be added to this array.

Returns:
Type:
ArgvArray

toString() → {string}

Converting pattern array to string

Source:
Returns:
Type:
string

toString() → {string}

Converting pattern array to string

Source:
Returns:
Type:
string

@alexeyp0708/argv_patterns. ArgvPattern

Class ArgvPattern create array containing [object ArgvElement] elements which are patterns

Constructor

new ArgvPattern()

Source:

Extends

Methods

(static) compareArgvToPatterns(argv, patterns, diff) → {ArgvArray}

Matches the argv parameters with the pattern, and returns the matches in [array ArgvArray].

Source:
See:
Parameters:
Name Type Description
argv string | Array | ArgvArray

Where string is the command line. Where Array- Argv array of command line parameters. Command line:

  • command1 command2
  • command "string from space" or command 'string from space'. Warn: quotes ( " and ') inside quotes are not recognized when parsing a string.
  • --option => option=true
  • --option=value or --option:value => option=value
  • --option value => option=value if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • --option --value or --option -v option option=--value or option=-v if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • -o option o=true
  • --o=value or -o:value => o=value
  • --o=value or -o:value => o=value
  • -o value => o=value if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • -o --value or -o -v => o=--value or o=-v if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
patterns string | Array | ArgvPattern

Where string is the command line. Where Array- Argv array of command line parameters. Command patterns:

  • command1 command2 command3 - the following command order must be present - command1 command2 command3.
  • command * * the following command order must be present - command any_string_without_spaces "any string"
  • command /hello|bay/i the following command order must be present - command hello or command bay, according to regular expressions. Option patterns:
  • --option => option=true
  • --option=value => option=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • -o => o=true
  • -o=value => o=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • -abc => a=true b=true c=true
  • -abc=value => a=true b=true c=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • [-o --option] or [--option -o] => option=true or short o=true
  • [-o --option value] or [--option value] or [-o value] => option=value or short o=value where 'value' solid_string | string from space | "string from space" | * | / regular_exr /
diff boolean | Array

If set to false, it will give an error if the parameter set by the template is missing. If set empty array, then the missing parameter will be added to this array.

Throws:

Error: Bad parameters - syntactically bad parameter or poorly constructed command line. Error: Throws an error if the parameter is set according to the pattern, but does not match the criteria of the pattern. Error: Throws an error if an extra parameter is passed. Throws an error if diff argument is false. Error: Throws an error if the parameter is required according to the pattern, but it is missing and the default value is not set in the pattern.

Returns:
Type:
ArgvArray

parameters that intersect with the pattern

(static) compareArgvToPatterns(argv, patterns, diff) → {ArgvArray}

Matches the argv parameters with the pattern, and returns the matches in [array ArgvArray].

Source:
See:
Parameters:
Name Type Description
argv string | Array | ArgvArray

Where string is the command line. Where Array- Argv array of command line parameters. Command line:

  • command1 command2
  • command "string from space" or command 'string from space'. Warn: quotes ( " and ') inside quotes are not recognized when parsing a string.
  • --option => option=true
  • --option=value or --option:value => option=value
  • --option value => option=value if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • --option --value or --option -v option option=--value or option=-v if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • -o option o=true
  • --o=value or -o:value => o=value
  • --o=value or -o:value => o=value
  • -o value => o=value if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
  • -o --value or -o -v => o=--value or o=-v if the parameter in the pattern is set to value (string|"string from space"|* |/regular expr/)
patterns string | Array | ArgvPattern

Where string is the command line. Where Array- Argv array of command line parameters. Command patterns:

  • command1 command2 command3 - the following command order must be present - command1 command2 command3.
  • command * * the following command order must be present - command any_string_without_spaces "any string"
  • command /hello|bay/i the following command order must be present - command hello or command bay, according to regular expressions. Option patterns:
  • --option => option=true
  • --option=value => option=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • -o => o=true
  • -o=value => o=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • -abc => a=true b=true c=true
  • -abc=value => a=true b=true c=value where 'value' solid_string | "string from space" | * | / regular_exr /
  • [-o --option] or [--option -o] => option=true or short o=true
  • [-o --option value] or [--option value] or [-o value] => option=value or short o=value where 'value' solid_string | string from space | "string from space" | * | / regular_exr /
diff boolean | Array

If set to false, it will give an error if the parameter set by the template is missing. If set empty array, then the missing parameter will be added to this array.

Throws:

Error: Bad parameters - syntactically bad parameter or poorly constructed command line. Error: Throws an error if the parameter is set according to the pattern, but does not match the criteria of the pattern. Error: Throws an error if an extra parameter is passed. Throws an error if diff argument is false. Error: Throws an error if the parameter is required according to the pattern, but it is missing and the default value is not set in the pattern.

Returns:
Type:
ArgvArray

parameters that intersect with the pattern

(static) elementsToPattern(argv) → {string}

Converting [object ArgvElement] elements from [array ArgvArray] to command line pattern

Source:
See:
Parameters:
Name Type Description
argv ArgvArray
Throws:

Error: Bad argument - Invalid argument

Returns:
Type:
string

Returns the assembled pattern

(static) elementsToPattern(argv) → {string}

Converting [object ArgvElement] elements from [array ArgvArray] to command line pattern

Source:
See:
Parameters:
Name Type Description
argv ArgvArray
Throws:

Error: Bad argument - Invalid argument

Returns:
Type:
string

Returns the assembled pattern

(static) getHelp(argv, pattern, descriptions) → {string}

Source:
Parameters:
Name Type Description
argv
pattern
descriptions object

{ '-':'this desc', }

Returns:
Type:
string

(static) getHelp(argv, pattern, descriptions) → {string}

Source:
Parameters:
Name Type Description
argv
pattern
descriptions object

{ '-':'this desc', }

Returns:
Type:
string

compare(argv, diff) → {ArgvArray}

Matches the argv parameters with the pattern, and returns the matches in [array ArgvArray]. See [method Argv.compareArgvToPatterns].

Source:
Parameters:
Name Type Description
argv string | Array | ArgvArray

argv parameters

diff

If set to false, it will give an error if the parameter set by the template is missing. If set empty array, then the missing parameter will be added to this array.

Returns:
Type:
ArgvArray

compare(argv, diff) → {ArgvArray}

Matches the argv parameters with the pattern, and returns the matches in [array ArgvArray]. See [method Argv.compareArgvToPatterns].

Source:
Parameters:
Name Type Description
argv string | Array | ArgvArray

argv parameters

diff

If set to false, it will give an error if the parameter set by the template is missing. If set empty array, then the missing parameter will be added to this array.

Returns:
Type:
ArgvArray

toString() → {string}

Converting pattern array to string

Source:
Returns:
Type:
string

toString() → {string}

Converting pattern array to string

Source:
Returns:
Type:
string