Adds helper functions
This commit is contained in:
parent
5e4b24eb5c
commit
3d44f04926
|
|
@ -66,15 +66,18 @@ pub(crate) fn make_pdf(args: &MakeConfig, _config: &Config) -> Result<()> {
|
|||
);
|
||||
};
|
||||
|
||||
// Make the target to build
|
||||
let file = make_file(args);
|
||||
// Identify special targets: Clean, Glossaries, All, List etc.
|
||||
match args.target {
|
||||
Some(MakeTargets::All) => make_all(args, file),
|
||||
Some(MakeTargets::All) => {
|
||||
// Make the target to build
|
||||
let file = make_file(args);
|
||||
make_all(args, file)
|
||||
}
|
||||
Some(MakeTargets::List) => make_list(args),
|
||||
Some(MakeTargets::Glossaries) => make_glossaries(args),
|
||||
Some(MakeTargets::Clean) => make_clean(args),
|
||||
None => {
|
||||
let file = make_file(args);
|
||||
launch_subprocess(args, file).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use std::{
|
|||
fs::File,
|
||||
io::{Read, Write},
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
sync::LazyLock,
|
||||
};
|
||||
|
||||
|
|
@ -182,10 +183,48 @@ pub(crate) fn simplify_add(
|
|||
|
||||
/// Make the glossaries
|
||||
pub(crate) fn make_glossaries(args: &MakeConfig) {
|
||||
todo!()
|
||||
use std::str;
|
||||
match Command::new("makeglossaries")
|
||||
.arg(format!("{:?}", target_name(&args.filename)))
|
||||
.output()
|
||||
{
|
||||
Err(e) => {
|
||||
println!(
|
||||
"An error has occured while trying to build the glossaries\n{:#?}",
|
||||
e
|
||||
)
|
||||
}
|
||||
Ok(o) => {
|
||||
println!("Program exited with status {}", o.status);
|
||||
if !o.stdout.is_empty() {
|
||||
println!("{:?}", str::from_utf8(&o.stdout));
|
||||
}
|
||||
if !o.stderr.is_empty() {
|
||||
println!("{:?}", str::from_utf8(&o.stderr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Make the working directory clean, by eliminating all temporary files
|
||||
pub(crate) fn make_clean(args: &MakeConfig) {
|
||||
todo!()
|
||||
let _ = args;
|
||||
let target = format!("{:?}", Path::new(&args.filename).file_stem().unwrap());
|
||||
let list_suff = [
|
||||
".aux", ".glg", ".glo", ".gls", ".ist", ".log", ".out", ".tex", ".toc",
|
||||
];
|
||||
let mut cmd = Command::new("rm");
|
||||
for s in list_suff {
|
||||
// The most ghetto *** I've done so far
|
||||
cmd.arg(format!("{}{}", &target[1..target.len() - 1], s));
|
||||
cmd.arg(format!("{}_build{}", &target[1..target.len() - 1], s));
|
||||
}
|
||||
cmd.arg(format!("{}_build{}", &target[1..target.len() - 1], ".tex"));
|
||||
|
||||
if let Err(e) = cmd.output() {
|
||||
println!(
|
||||
"[ERRR] An error has occured when executing the clean target \n {:#?}",
|
||||
e
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ pub(crate) enum LineType {
|
|||
StartingSequence,
|
||||
|
||||
/// Strange end sequence
|
||||
#[token("{/usr/share")]
|
||||
#[token(" ){/")]
|
||||
EndSequence,
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue