-
Notifications
You must be signed in to change notification settings - Fork 1
/
command.rs
43 lines (32 loc) · 729 Bytes
/
command.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Commands are executed as such
//!
//! ```text
//! {cmd header}
//! {args}
//! ```
//!
//! where {cmd data} is one line of RON
//! but {args} can be several lines
use std::collections::HashMap;
use std::mem::Discriminant;
use async_trait::async_trait;
use derive_build::Build;
use derive_discriminant::Discriminant;
use crate::Ctx;
mod zsh;
mod bash;
/// The command we are executing
#[derive(Discriminant)]
enum Cmd {
/// a zsh script to execute
Zsh,
Bash,
}
#[async_trait]
trait Command {
async fn execute(&self, exec: Ctx, input: &str) -> anyhow::Result<String>;
}
fn this_requires_unsize() {
let cmd1: Box<dyn Command> = Cmd::Zsh.cast();
let cmd2: Box<dyn Command> = Cmd::Bash.cast();
}