This commit is contained in:
Breval Ferrari 2025-06-01 23:33:58 +02:00
parent 3168370a37
commit 1f2d23e051
Signed by: breval
GPG key ID: 5310EC237FE283D1
2 changed files with 20 additions and 8 deletions

View file

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

View file

@ -1,12 +1,22 @@
mod cli;
use clap::Parser;
use bliplib::{compiler::VariableChange, parser::Parser};
use clap::Parser as _;
use cli::Cli;
fn main() {
let cli = Cli::parse();
use 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!(),
Memo(memo) => todo!(),
}