in antlir/vm/vm.py [0:0]
def setup_cli(cls, parser) -> None:
"""
Add attributes defined on this type to the parser.
Subclasses of `VMExecOpts` should overload this classmethod to provide
their own arguments. Subclass implementors should take care to call
`super(<SubClassType>, cls).setup_cli(parser)` to make sure that these
base class args are added.
"""
parser.add_argument(
"--bind-repo-ro",
action="store_true",
default=True,
help="Makes a read-only bind-mount of the current Buck project "
"into the vm at the same location as it is on the host. This is "
"needed to run binaries that are built to be run in-place and for "
"binaries that make assumptions about files being available "
"relative to the binary.",
)
parser.add_argument(
"--append-console",
# This is used when the bare option with no arg is used.
const=None,
# This is used when no swicth is provided
default=subprocess.DEVNULL,
dest="console",
nargs="?",
# This is used only when an argument is provided
type=Path.from_argparse,
help="Where to send console output. If "
"--append-console=/path/to/file is "
"provided, append the console output to the supplied file. If "
"just --append-console is provided, send to stdout for easier "
"debugging. By default the console output is supressed.",
)
parser.add_argument(
"--opts",
type=vm_opts_t.parse_raw,
help="Path to a serialized vm_opts_t instance containing "
"configuration details for the vm.",
required=True,
)
parser.add_argument(
"--debug",
action="store_true",
default=False,
help="Show debug logs",
)
parser.add_argument(
"--shell",
choices=list(ShellMode),
type=ShellMode,
default=None,
help="Connect to an interactive shell inside the VM via the "
"specified method. When this option is used, no additional "
"commands or automation is allowed. When you exit the shell "
"the VM will terminate.",
)
parser.add_argument(
"--timeout",
dest="timeout_ms",
# We want to allow the cli to specify seconds, mostly because that
# is what external tools that invoke this will use. But internally
# we want to use millis, so we'll convert it right here to avoid
# any confusion later.
type=lambda t: int(t) * 1000,
# Inside FB some tools set an env var instead of passing an
# option. Maybe we can get rid of this if we fix the few
# tools that call this.
default=os.environ.get("TIMEOUT", DEFAULT_TIMEOUT_MS),
help="How many seconds to allow the VM to run. The clock starts "
"as soon as the emulator is spawned.",
)