nestrs-cli-rs 0.1.0

Rust port of the Nest CLI for the nestrs organization.
Documentation
//! Upstream source: `../nest-cli/actions/abstract.action.ts`.

use crate::commands::Input;

use super::{ActionInvocation, ActionKind, ActionSpec, action_spec};

/// Typed Rust equivalent of upstream `AbstractAction`.
pub trait AbstractAction {
    fn kind(&self) -> ActionKind;

    fn spec(&self) -> &'static ActionSpec {
        action_spec(self.kind()).expect("action spec must be registered")
    }

    fn handle(
        &self,
        inputs: Vec<Input>,
        options: Vec<Input>,
        extra_flags: Vec<String>,
    ) -> ActionInvocation {
        ActionInvocation {
            kind: self.kind(),
            inputs,
            options,
            extra_flags,
        }
    }
}