Skip to content

cli

Command-line interface for the Electrophysiology Manipulator Link.

Usage

Instantiate CLI and call parse_args() to get the parsed arguments.

CLI().parse_args()

CLI

Command-line interface for the Electrophysiology Manipulator Link.

Configures the CLI parser and options.

Source code in src/ephys_link/front_end/cli.py
@final
class CLI:
    """Command-line interface for the Electrophysiology Manipulator Link.

    Configures the CLI parser and options.
    """

    def __init__(self) -> None:
        """Initialize CLI parser."""

        self._parser = ArgumentParser(
            description="Electrophysiology Manipulator Link: a Socket.IO interface for manipulators in electrophysiology experiments.",
            prog="python -m ephys-link",
        )

        _ = self._parser.add_argument(
            "-b", "--background", dest="background", action="store_true", help="Skip configuration window."
        )
        _ = self._parser.add_argument(
            "-i",
            "--ignore-updates",
            dest="ignore_updates",
            action="store_true",
            help="Skip (ignore) checking for updates.",
        )
        _ = self._parser.add_argument(
            "-t",
            "--type",
            type=str,
            dest="type",
            default="ump-4",
            help='Manipulator type (i.e. "ump-4", "pathfinder-mpm", "fake"). Default: "ump-4".',
        )
        _ = self._parser.add_argument(
            "-d",
            "--debug",
            dest="debug",
            action="store_true",
            help="Enable debug mode.",
        )
        _ = self._parser.add_argument(
            "-p",
            "--use-proxy",
            dest="use_proxy",
            action="store_true",
            help="Enable proxy mode.",
        )
        _ = self._parser.add_argument(
            "-a",
            "--proxy-address",
            type=str,
            default="proxy2.virtualbrainlab.org",
            dest="proxy_address",
            help="Proxy IP address.",
        )
        _ = self._parser.add_argument(
            "--mpm-port",
            type=int,
            default=8080,
            dest="mpm_port",
            help="Port New Scale Pathfinder MPM's server is on. Default: 8080.",
        )
        _ = self._parser.add_argument(
            "-s",
            "--serial",
            type=str,
            default="no-e-stop",
            dest="serial",
            nargs="?",
            help="Emergency stop serial port (i.e. COM3). Default: disables emergency stop.",
        )
        _ = self._parser.add_argument(
            "-v",
            "--version",
            action="version",
            version=f"Electrophysiology Manipulator Link v{version}",
            help="Print version and exit.",
        )

    def parse_args(self) -> EphysLinkOptions:
        """Parse arguments and return them

        Returns:
            Parsed arguments
        """
        return EphysLinkOptions(**vars(self._parser.parse_args()))  # pyright: ignore [reportAny]

__init__()

Initialize CLI parser.

Source code in src/ephys_link/front_end/cli.py
def __init__(self) -> None:
    """Initialize CLI parser."""

    self._parser = ArgumentParser(
        description="Electrophysiology Manipulator Link: a Socket.IO interface for manipulators in electrophysiology experiments.",
        prog="python -m ephys-link",
    )

    _ = self._parser.add_argument(
        "-b", "--background", dest="background", action="store_true", help="Skip configuration window."
    )
    _ = self._parser.add_argument(
        "-i",
        "--ignore-updates",
        dest="ignore_updates",
        action="store_true",
        help="Skip (ignore) checking for updates.",
    )
    _ = self._parser.add_argument(
        "-t",
        "--type",
        type=str,
        dest="type",
        default="ump-4",
        help='Manipulator type (i.e. "ump-4", "pathfinder-mpm", "fake"). Default: "ump-4".',
    )
    _ = self._parser.add_argument(
        "-d",
        "--debug",
        dest="debug",
        action="store_true",
        help="Enable debug mode.",
    )
    _ = self._parser.add_argument(
        "-p",
        "--use-proxy",
        dest="use_proxy",
        action="store_true",
        help="Enable proxy mode.",
    )
    _ = self._parser.add_argument(
        "-a",
        "--proxy-address",
        type=str,
        default="proxy2.virtualbrainlab.org",
        dest="proxy_address",
        help="Proxy IP address.",
    )
    _ = self._parser.add_argument(
        "--mpm-port",
        type=int,
        default=8080,
        dest="mpm_port",
        help="Port New Scale Pathfinder MPM's server is on. Default: 8080.",
    )
    _ = self._parser.add_argument(
        "-s",
        "--serial",
        type=str,
        default="no-e-stop",
        dest="serial",
        nargs="?",
        help="Emergency stop serial port (i.e. COM3). Default: disables emergency stop.",
    )
    _ = self._parser.add_argument(
        "-v",
        "--version",
        action="version",
        version=f"Electrophysiology Manipulator Link v{version}",
        help="Print version and exit.",
    )

parse_args()

Parse arguments and return them

Returns:

Type Description
EphysLinkOptions

Parsed arguments

Source code in src/ephys_link/front_end/cli.py
def parse_args(self) -> EphysLinkOptions:
    """Parse arguments and return them

    Returns:
        Parsed arguments
    """
    return EphysLinkOptions(**vars(self._parser.parse_args()))  # pyright: ignore [reportAny]