Executable

The Executable is derived from Program, which represents an executable command line program. In addition, it offers an API to subprocess.Popen, so an abstracted command line program can be launched.

Features:

  • Launch an abstracted CLI program using subproess.Popen.

  • Setup and modify the environment for the launched program.

  • Provide a line-based STDOUT reader as generator.

Simple Example

The following example implements a portion of the git program and its --version argument.

Program Definition

Git program defining –version argument.
class Git(Executable):
  _executableNames: ClassVar[Dict[str, str]] = {
    "Darwin":  "git",
    "FreeBSD": "git",
    "Linux":   "git",
    "Windows": "git.exe"
  }

  @CLIArgument()
  class FlagVersion(LongFlag, name="version"):
    """Print the version information."""

Program Usage

Usage of the abstracted Git program.
git = Git()
git[git.FlagVersion] = True

git.StartProcess()
for line in git.GetLineReader():
  print(line)