cli: add dev command for enums experiment
This commit is contained in:
parent
56ec11e143
commit
db9228dec4
4 changed files with 43 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -66,6 +66,7 @@ dependencies = [
|
||||||
"eval",
|
"eval",
|
||||||
"ir",
|
"ir",
|
||||||
"owo-colors",
|
"owo-colors",
|
||||||
|
"prowocessing",
|
||||||
"ron",
|
"ron",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|
|
@ -12,6 +12,7 @@ clap = { workspace = true, features = [ "derive", "env" ] }
|
||||||
dirs = "5"
|
dirs = "5"
|
||||||
eval = { path = "../eval" }
|
eval = { path = "../eval" }
|
||||||
ir = { path = "../ir" }
|
ir = { path = "../ir" }
|
||||||
|
prowocessing = { path = "../prowocessing"}
|
||||||
owo-colors = "4"
|
owo-colors = "4"
|
||||||
ron = "0.8"
|
ron = "0.8"
|
||||||
serde = { workspace = true, features = [ "derive" ] }
|
serde = { workspace = true, features = [ "derive" ] }
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::{fs, path::PathBuf};
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use config::{CliConfigs, Config};
|
use config::{CliConfigs, Config};
|
||||||
|
use dev::DevCommands;
|
||||||
use welcome_msg::print_startup_msg;
|
use welcome_msg::print_startup_msg;
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
|
@ -24,7 +25,10 @@ enum Commands {
|
||||||
/// What file contains the pipeline to evaluate.
|
/// What file contains the pipeline to evaluate.
|
||||||
source: PathBuf,
|
source: PathBuf,
|
||||||
},
|
},
|
||||||
Dev,
|
Dev {
|
||||||
|
#[command(subcommand)]
|
||||||
|
dev_command: DevCommands,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -46,8 +50,34 @@ fn main() {
|
||||||
machine.feed(ir);
|
machine.feed(ir);
|
||||||
machine.eval_full();
|
machine.eval_full();
|
||||||
}
|
}
|
||||||
Commands::Dev => {
|
Commands::Dev { dev_command } => dev_command.run(),
|
||||||
println!("Hello world!");
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod dev {
|
||||||
|
use clap::Subcommand;
|
||||||
|
use prowocessing::experimental::enum_based::{Pipeline, PipelineBuilder};
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub(crate) enum DevCommands {
|
||||||
|
Enums { test_str: String },
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DevCommands {
|
||||||
|
pub fn run(self) {
|
||||||
|
match self {
|
||||||
|
DevCommands::Enums { test_str } => {
|
||||||
|
let upr = PipelineBuilder::new()
|
||||||
|
.insert(prowocessing::experimental::enum_based::Instruction::Uppercase)
|
||||||
|
.build();
|
||||||
|
let lwr = PipelineBuilder::new()
|
||||||
|
.insert(prowocessing::experimental::enum_based::Instruction::Lowercase)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
println!("Upr: {}", upr.run(test_str.clone()));
|
||||||
|
println!("Lwr: {}", lwr.run(test_str.clone()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use experimental::enum_based::{Instruction, PipelineBuilder};
|
||||||
|
|
||||||
/// just some experiments, to test whether the architecture i want is even possible (or how to do it). probably temporary.
|
/// just some experiments, to test whether the architecture i want is even possible (or how to do it). probably temporary.
|
||||||
/// Gonna first try string processing...
|
/// Gonna first try string processing...
|
||||||
mod experimental {
|
pub mod experimental {
|
||||||
pub mod enum_based {
|
pub mod enum_based {
|
||||||
pub enum Instruction {
|
pub enum Instruction {
|
||||||
Uppercase,
|
Uppercase,
|
||||||
|
@ -41,6 +41,7 @@ mod experimental {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn insert(mut self, instr: Instruction) -> Self {
|
pub fn insert(mut self, instr: Instruction) -> Self {
|
||||||
self.pipeline.push(instr);
|
self.pipeline.push(instr);
|
||||||
self
|
self
|
||||||
|
@ -66,6 +67,12 @@ mod experimental {
|
||||||
Pipeline { pipeline: res }
|
Pipeline { pipeline: res }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for PipelineBuilder {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue