Compare commits
2 commits
71dddade6a
...
2c147fd77b
Author | SHA1 | Date | |
---|---|---|---|
2c147fd77b | |||
7994cd4f2b |
8 changed files with 29 additions and 26 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -161,6 +161,15 @@ version = "0.6.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
|
||||
|
||||
[[package]]
|
||||
name = "cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"executor",
|
||||
"ir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
|
@ -419,15 +428,6 @@ version = "1.19.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[package]]
|
||||
name = "pl-cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"executor",
|
||||
"ir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.17.10"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "pl-cli"
|
||||
name = "cli"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::{fs, path::PathBuf};
|
||||
|
||||
use clap::Parser;
|
||||
use executor::{execute_all, Executors};
|
||||
use executor::Executors;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct Args {
|
||||
|
@ -16,5 +16,5 @@ fn main() {
|
|||
.expect("reading IR failed — come back to this later handle errors properly");
|
||||
let pl = ir::from_ron(&f).expect("handle me properly");
|
||||
|
||||
execute_all(pl);
|
||||
dbg!(pl);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
pub mod read {
|
||||
use image::{io::Reader as ImageReader, DynamicImage};
|
||||
use rpl::instructions::read::{Read, SourceType};
|
||||
use ir::instruction::read::{Read, SourceType};
|
||||
|
||||
pub fn read(Read { source, .. }: Read) -> DynamicImage {
|
||||
// TODO: actual error handling
|
||||
|
@ -15,7 +15,7 @@ pub mod read {
|
|||
|
||||
pub mod write {
|
||||
use image::{DynamicImage, ImageFormat};
|
||||
use rpl::instructions::write::{TargetFormat, TargetType, Write};
|
||||
use ir::instruction::write::{TargetFormat, TargetType, Write};
|
||||
|
||||
pub fn write(Write { target, format }: Write, input_data: &DynamicImage) {
|
||||
input_data
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rpl::instructions::{Filter, Instruction};
|
||||
use ir::instruction::{Filter, Kind};
|
||||
|
||||
use crate::value::Dynamic;
|
||||
mod instructions;
|
||||
|
@ -6,12 +6,12 @@ mod instructions;
|
|||
pub struct Executor;
|
||||
|
||||
impl crate::Executor for Executor {
|
||||
fn execute(instruction: Instruction, input: Option<Dynamic>) -> Option<Dynamic> {
|
||||
fn execute(instruction: Kind, input: Option<Dynamic>) -> Option<Dynamic> {
|
||||
match instruction {
|
||||
Instruction::Read(read_instruction) => {
|
||||
Kind::Read(read_instruction) => {
|
||||
Some(Dynamic::Image(instructions::read::read(read_instruction)))
|
||||
}
|
||||
Instruction::Write(write_instruction) => {
|
||||
Kind::Write(write_instruction) => {
|
||||
instructions::write::write(
|
||||
write_instruction,
|
||||
match input {
|
||||
|
@ -21,10 +21,10 @@ impl crate::Executor for Executor {
|
|||
);
|
||||
None
|
||||
}
|
||||
Instruction::Math(_) => todo!(),
|
||||
Instruction::Blend(_) => todo!(),
|
||||
Instruction::Noise(_) => todo!(),
|
||||
Instruction::Filter(filter_instruction) => match filter_instruction {
|
||||
Kind::Math(_) => todo!(),
|
||||
Kind::Blend(_) => todo!(),
|
||||
Kind::Noise(_) => todo!(),
|
||||
Kind::Filter(filter_instruction) => match filter_instruction {
|
||||
Filter::Invert => Some(Dynamic::Image(instructions::filters::invert::invert(
|
||||
match input {
|
||||
Some(Dynamic::Image(img)) => img,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rpl::instructions::Instruction;
|
||||
use ir::instruction::Kind;
|
||||
use value::Dynamic;
|
||||
|
||||
mod debug;
|
||||
|
@ -17,10 +17,10 @@ pub enum Executors {
|
|||
}
|
||||
|
||||
trait Executor {
|
||||
fn execute(instruction: Instruction, input: Option<Dynamic>) -> Option<Dynamic>;
|
||||
fn execute(instruction: Kind, input: Option<Dynamic>) -> Option<Dynamic>;
|
||||
}
|
||||
|
||||
pub fn execute_all(instructions: Vec<Instruction>) {
|
||||
pub fn execute_all(instructions: Vec<Kind>) {
|
||||
let mut tmp = None;
|
||||
|
||||
for instruction in instructions {
|
||||
|
|
|
@ -7,6 +7,9 @@ pub mod instruction;
|
|||
pub type Map<K, V> = ahash::AHashMap<K, V>;
|
||||
pub type Set<V> = ahash::AHashSet<V>;
|
||||
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if the parsed source is not a valid graph IR.
|
||||
pub fn from_ron(source: &str) -> ron::error::SpannedResult<GraphIr> {
|
||||
ron::from_str(source)
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
just nushell
|
||||
typst typst-lsp
|
||||
mold
|
||||
cargo-nextest
|
||||
cargo-nextest cargo-watch
|
||||
];
|
||||
})
|
||||
];
|
||||
|
|
Loading…
Add table
Reference in a new issue