Files
mize/marts/src/sci/mod.rs
2026-10-14 01:50:08 +02:00

32 lines
991 B
Rust

use mize::*;
pub mod timetrack;
use clap::Command;
pub fn part_sci(mize: &mut Mize) -> MizeResult<()> {
part_add_thought(mize)?;
Ok(())
}
pub fn part_add_thought(mize: &mut Mize) -> MizeResult<()> {
use crate::generated::spacetime::add_thought;
let mut cli = mize.get_part_native::<crate::CliPart>("cli")?;
cli.set_command("sci");
cli.subcommand(Command::new("inputThought").alias("ti"), |_matches, mut mize| {
let tmp_file = std::env::temp_dir().join(format!(
"sc2-input-thought-{}.txt",
chrono::Utc::now().timestamp()
));
crate::cli_spawn(&mut mize, format!("nvim {}", tmp_file.display()))?;
let new_file_content = std::fs::read_to_string(&tmp_file)
.map_err(|e| mize_err!("Failed to read temp file: {}", e))?;
let _ = std::fs::remove_file(&tmp_file);
let spacetime = mize.get_part_native::<crate::SpacetimePart>("spacetime")?;
spacetime.con().reducers.add_thought(new_file_content)?;
Ok(())
})?;
Ok(())
}