Command-line-command plugin

Description

The command-line-command plugin is used for executing arbitrary command lines. This plugin can be used for constructing the command line for commands that do not have a corresponding plugin available.

Mandatory settings

The configuration of the command-line-command must contain the following settings:

command-line

The command-line to execute. There are two different usages:

  • No identification key: Set one command line as a list of separate arguments. This form is only usable if only one line needs to be executed.
  • With identification key: Make a map with arbitrary keys, where each associated value is one command line, described as a list of separate arguments. This form is usable if one or more lines need to be executed. Multiple commands are executed in the order the identification keys are defined.

Note: see the documentation of wordexp (3) for the limitations on what characters are not allowed in the command-line command.

Optional settings

The configuration of the command-line-command plugin may contain the following settings:

patterns

A list of patterns to apply on the command line. See Patterns (5).

enviroment

A list of environment variables that should be set before the commands are executed. See Environment (5).

working-dir

The working directory of the command. Can be an absolute path are a relative one w.r.t. the path to the considered configuration file. Commands that should be executed relative to the current working dir can use the {EH_WORKING_DIR} pattern.

Example

Configuration

commands:                       # Define the commands that can be run
    example: run the command-line example

patterns:                       # Define the patterns that can be used
    EXAMPLE_PATTERN:            # Define the EXAMPLE_PATTERN.
        default-values:         # Define the default value
            - world!

example:
    - command-line-command      # Use the command-line-command plugin when running the 'example' command

command-line-command:           # Command-line-command configuration settings
    example:                    # Settings specific to the 'example' command
        environment:            # Define the environment
            EXAMPLE_ENVIRONMENT: hello
        patterns:               # Define the patterns that are used
            - EXAMPLE_PATTERN
        command-line:           # Define 2 command lines
            - hello: [echo, "${EXAMPLE_ENVIRONMENT}"]
            - world:            # The same as [echo, "{EXAMPLE_PATTERN}"]
                - echo
                - "{EXAMPLE_PATTERN}"
            - workingdir: [ echo, working, directory, is, "$(pwd)"]     # Print out the current working directory
        working-dir: /tmp       # Set the working directory to a predefined value

Usage

Save the example to an exec-helper configuration file and execute in the same directory:

eh example

See also

See exec-helper (1) for information about the usage of exec-helper.

See Configuration (5) for information about the configuration file format.

See Plugins (5) for information about the configuration file format.