idmtools.entities.command_line module

Defines the CommandLine class that represents our remote command line to be executed.

Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.

class idmtools.entities.command_line.CommandLine(executable=None, *args, is_windows: bool = False, raw_args: Optional[List[Any]] = None, **kwargs)

Bases: object

A class to construct command-line strings from executable, options, and params.

__init__(executable=None, *args, is_windows: bool = False, raw_args: Optional[List[Any]] = None, **kwargs)

Initialize CommandLine.

Parameters:
  • executable – Executable

  • *args – Additional Arguments

  • is_windows – is the command for windows

  • raw_args – Any raw arguments

  • **kwargs – Keyword arguments

is_windows: bool = False

Is this a command line for a windows system

property executable: str

Return executable as string.

Returns:

Executable

add_argument(arg)

Add argument.

Parameters:

arg – Argument string

Returns:

None

add_raw_argument(arg)

Add an argument that won’t be quote on format.

Parameters:

arg – arg

Returns:

None

add_option(option, value)

Add a command-line option.

Parameters:
  • option – Option to add

  • value – Value of option

Returns:

None

property options

Options as a string.

Returns:

Options string

property arguments

The CommandLine arguments.

Returns:

Arguments as string

property raw_arguments

Raw arguments(arguments not to be parsed).

Returns:

Raw arguments as a string

property cmd

Converts command to string.

Returns:

Command as string

static from_string(command: str, as_raw_args: bool = False) CommandLine

Creates a command line object from string.

Parameters:
  • command – Command

  • as_raw_args – When set to true, arguments will preserve the quoting provided

Returns:

CommandLine object from string