main_ -> _cli

This commit is contained in:
🪞👃🪞 2024-10-06 02:30:59 +03:00
parent 9b8a14df0e
commit 323a8aeb5f
4 changed files with 15 additions and 15 deletions

View file

@ -11,12 +11,12 @@ path = "src/lib.rs"
[[bin]] [[bin]]
name = "tek_sequencer" name = "tek_sequencer"
path = "src/main_sequencer.rs" path = "src/sequencer_cli.rs"
[[bin]] [[bin]]
name = "tek_arranger" name = "tek_arranger"
path = "src/main_arranger.rs" path = "src/arranger_cli.rs"
[[bin]] [[bin]]
name = "tek_transport" name = "tek_transport"
path = "src/main_transport.rs" path = "src/transport_cli.rs"

View file

@ -1,6 +1,8 @@
include!("lib.rs"); include!("lib.rs");
use tek_core::clap::{self, Parser}; use tek_core::clap::{self, Parser};
pub fn main () -> Usually<()> { ArrangerCli::parse().run() } pub fn main () -> Usually<()> { ArrangerCli::parse().run() }
/// Parses CLI arguments to the `tek_arranger` invocation. /// Parses CLI arguments to the `tek_arranger` invocation.
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
#[command(version, about, long_about = None)] #[command(version, about, long_about = None)]
@ -21,6 +23,7 @@ pub struct ArrangerCli {
#[arg(short, long, default_value_t = 8)] #[arg(short, long, default_value_t = 8)]
scenes: usize, scenes: usize,
} }
impl ArrangerCli { impl ArrangerCli {
/// Run the arranger TUI from CLI arguments. /// Run the arranger TUI from CLI arguments.
fn run (&self) -> Usually<()> { fn run (&self) -> Usually<()> {

View file

@ -1,8 +1,6 @@
//! Phrase editor. //! Phrase editor.
include!("lib.rs"); include!("lib.rs");
pub fn main () -> Usually<()> { pub fn main () -> Usually<()> { SequencerCli::parse().run() }
Tui::run(Arc::new(RwLock::new(crate::Sequencer::from_args()))).map(|_|())
}
use tek_core::clap::{self, Parser}; use tek_core::clap::{self, Parser};
@ -19,25 +17,24 @@ pub struct SequencerCli {
#[arg(short, long)] transport: Option<bool> #[arg(short, long)] transport: Option<bool>
} }
impl Sequencer<Tui> { impl SequencerCli {
pub fn from_args () -> Self { fn run (&self) -> Usually<()> {
let args = SequencerCli::parse(); let mut seq = Sequencer::new("");
let mut seq = Self::new(""); if let Some(name) = self.name.as_ref() {
if let Some(name) = args.name {
seq.name = Arc::new(RwLock::new(name.clone())); seq.name = Arc::new(RwLock::new(name.clone()));
} }
if let Some(ppq) = args.ppq { if let Some(ppq) = self.ppq {
seq.ppq = ppq; seq.ppq = ppq;
} }
if let Some(length) = args.length { if let Some(length) = self.length {
// TODO FIXME WTF // TODO FIXME WTF
//if let Some(phrase) = seq.phrase.as_mut() { //if let Some(phrase) = seq.phrase.as_mut() {
//phrase.write().unwrap().length = length; //phrase.write().unwrap().length = length;
//} //}
} }
if args.transport == Some(true) { if self.transport == Some(true) {
seq.transport = Some(Arc::new(RwLock::new(TransportToolbar::new(None)))); seq.transport = Some(Arc::new(RwLock::new(TransportToolbar::new(None))));
} }
seq Tui::run(Arc::new(RwLock::new(seq))).map(|_|())
} }
} }