feat(derive): Add derive macro for interface
This commit is contained in:
@@ -7,3 +7,4 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
eyre = { workspace = true }
|
||||
clap = "4.1.6"
|
||||
|
@@ -1,20 +1,44 @@
|
||||
pub mod std;
|
||||
|
||||
pub trait Action {}
|
||||
pub enum ActionArg<'a> {
|
||||
Required { name: &'a str, description: &'a str },
|
||||
Optional { name: &'a str, description: &'a str },
|
||||
}
|
||||
|
||||
pub struct InputArg<'a> {
|
||||
name: &'a str,
|
||||
value: &'a str,
|
||||
}
|
||||
|
||||
pub struct ActionArgs<'a> {
|
||||
pub name: &'a str,
|
||||
pub args: Vec<ActionArg<'a>>,
|
||||
}
|
||||
|
||||
pub trait Action {
|
||||
fn action<'a>(&self) -> ActionArgs<'a>;
|
||||
fn execute(&self, args: &[&InputArg]) -> eyre::Result<()>;
|
||||
}
|
||||
|
||||
pub trait Plugin {}
|
||||
|
||||
pub struct CharBuilder;
|
||||
pub struct CharBuilder {
|
||||
actions: Vec<Box<dyn Action>>,
|
||||
}
|
||||
|
||||
impl CharBuilder {
|
||||
pub fn new() -> Self {
|
||||
CharBuilder
|
||||
CharBuilder {
|
||||
actions: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_context<C>(mut self, context: C) -> Self {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn add_action(mut self, action: impl Action) -> Self {
|
||||
pub fn add_action(mut self, action: impl Into<Box<dyn Action>>) -> Self {
|
||||
self.actions.push(action.into());
|
||||
self
|
||||
}
|
||||
|
||||
@@ -23,6 +47,7 @@ impl CharBuilder {
|
||||
}
|
||||
|
||||
pub fn execute(mut self) -> eyre::Result<()> {
|
||||
//clap::Command::new("").arg(a)
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
pub struct Context {}
|
||||
pub struct Plugin {}
|
||||
|
||||
impl Default for Context {
|
||||
impl crate::Plugin for Plugin {}
|
||||
|
||||
impl Default for Plugin {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
Reference in New Issue
Block a user