diff --git a/src/cli/cli.rs b/src/cli/cli.rs index eaeb75f..8c331dd 100644 --- a/src/cli/cli.rs +++ b/src/cli/cli.rs @@ -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::)] #[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 { - self.slopes.iter().map(|(id, (s, e))| (id, (s.as_ref(), e))) + pub(super) fn slopes(&self) -> impl Iterator { + self.slopes + .iter() + .map(|(name, (v, e))| (name.as_ref(), (v, e))) } } impl InputGroup { - pub(super) fn get<'a>(&'a self) -> Box { + pub(super) fn get(&self) -> Box { self.input .as_ref() .map(|i| Box::new(i.clone().0) as Box) diff --git a/src/cli/main.rs b/src/cli/main.rs index e0307e7..ddf5bb7 100644 --- a/src/cli/main.rs +++ b/src/cli/main.rs @@ -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::>(), + play_opts.variables().map(|(v, _)| *v).collect::>(), + ); + } Export(export_opts) => todo!(), Memo(memo) => todo!(), }