Compare commits

...
Sign in to create a new pull request.

1 commit
main ... dirty

Author SHA1 Message Date
Breval Ferrari
1f2d23e051
g 2025-06-01 23:33:58 +02:00
2 changed files with 20 additions and 8 deletions

View file

@ -6,7 +6,7 @@ use std::{
fs::File, fs::File,
io::{self, Cursor, Read, stdin}, io::{self, Cursor, Read, stdin},
ops::Not, ops::Not,
str::{Bytes, FromStr}, str::FromStr,
}; };
use anyhow::anyhow; use anyhow::anyhow;
@ -47,7 +47,7 @@ pub(super) enum Cli {
#[derive(Parser, Clone, Getters)] #[derive(Parser, Clone, Getters)]
#[cfg_attr(debug_assertions, derive(Debug))] #[cfg_attr(debug_assertions, derive(Debug))]
#[getset(get)] #[getset(get = "pub(super)")]
pub(super) struct PlayOpts { pub(super) struct PlayOpts {
/// Use this sheet music [default: stdin] /// Use this sheet music [default: stdin]
#[command(flatten)] #[command(flatten)]
@ -72,7 +72,7 @@ pub(super) struct PlayOpts {
/// Add a slope expression named NAME which mutates the VARIABLE with the result of EXPR each frame /// Add a slope expression named NAME which mutates the VARIABLE with the result of EXPR each frame
#[arg(short, long = "slope", value_name = "NAME:VARIABLE=EXPR", value_parser = parse_key_tuple::<LetterString, Letter, Expression>)] #[arg(short, long = "slope", value_name = "NAME:VARIABLE=EXPR", value_parser = parse_key_tuple::<LetterString, Letter, Expression>)]
#[getset(skip)] #[getset(skip)]
slopes: Vec<(String, (LetterString, Expression))>, slopes: Vec<(LetterString, (char, Expression))>,
} }
impl PlayOpts { impl PlayOpts {
@ -84,13 +84,15 @@ impl PlayOpts {
self.macros.iter().map(|(c, s)| (c.as_ref(), s)) self.macros.iter().map(|(c, s)| (c.as_ref(), s))
} }
pub(super) fn slopes(&self) -> impl Iterator<Item = (&String, (&String, &Expression))> { pub(super) fn slopes(&self) -> impl Iterator<Item = (&String, (&char, &Expression))> {
self.slopes.iter().map(|(id, (s, e))| (id, (s.as_ref(), e))) self.slopes
.iter()
.map(|(name, (v, e))| (name.as_ref(), (v, e)))
} }
} }
impl InputGroup { impl InputGroup {
pub(super) fn get<'a>(&'a self) -> Box<dyn Read> { pub(super) fn get(&self) -> Box<dyn Read> {
self.input self.input
.as_ref() .as_ref()
.map(|i| Box::new(i.clone().0) as Box<dyn Read>) .map(|i| Box::new(i.clone().0) as Box<dyn Read>)

View file

@ -1,12 +1,22 @@
mod cli; mod cli;
use clap::Parser; use bliplib::{compiler::VariableChange, parser::Parser};
use clap::Parser as _;
use cli::Cli; use cli::Cli;
fn main() { fn main() {
let cli = Cli::parse(); let cli = Cli::parse();
use Cli::*; use Cli::*;
match cli { match cli {
Play(play_opts) => todo!(), Play(play_opts) => {
let parser = Parser::new(
play_opts.notes(),
play_opts
.slopes()
.map(|(s, (v, e))| (s, VariableChange(*v, e.clone())))
.collect::<Vec<_>>(),
play_opts.variables().map(|(v, _)| *v).collect::<Vec<_>>(),
);
}
Export(export_opts) => todo!(), Export(export_opts) => todo!(),
Memo(memo) => todo!(), Memo(memo) => todo!(),
} }