/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import { type Command } from "@oclif/core"; import type { Machine } from "jssm"; import type { StateHandler } from "./handlers/index.js"; import { BaseCommand } from "./library/index.js"; /** * A base CLI command that uses an internal state machine to govern its behavior. Subclasses must provide a state * machine and a handler. * * When the command is run, the state machine is initialized, and the command loops over the state machine, calling its * {@link StateHandler} with the current state. * * @remarks * * The command provides a `testMode` flag, which subclasses are expected to check when handling states. If in test mode, * all handled states should immediately return true. This enables tests to verify that new states are handled in some * way. * * The command also provides a `state` flag that can be used to initialize the state machine to a specific state. This * is intended for testing. */ export declare abstract class StateMachineCommand extends BaseCommand { static flags: { testMode: import("@oclif/core/interfaces").BooleanFlag; state: import("@oclif/core/interfaces").OptionFlag; }; /** * The state machine used by the command. */ abstract get machine(): Machine; /** * Contextual data that can be passed to state handlers. The type is unknown here; subclasses are expected to * provide a concrete type. */ abstract get data(): unknown; abstract set data(d: unknown); /** * The {@link StateHandler} used by the command. Subclasses should set this in their init() method. */ abstract handler: StateHandler | undefined; init(): Promise; /** * Wires up some hooks on the state machine to do machine-wide logging. */ protected initMachineHooks(): Promise; /** * Loops over the state machine and calls its handler for each machine state. Subclasses should call this at the end * of their `run` method. */ protected stateLoop(): Promise; /** * Runs the command by calling the (infinite) stateLoop method. */ run(): Promise; } //# sourceMappingURL=stateMachineCommand.d.ts.map