Crate libtmplgen
source ·Expand description
libtmplgen can be used for querying different language-specific package managers and generating Void Linux build templates for them. Currently the following providers are supported:
Usage
The following will write a template for tmplgen
in $XBPS_DISTDIR/srcpkgs/tmplgen/template
use libtmplgen::*;
use std::fs::File;
use std::io::prelude::*;
let template = TmplBuilder::new("tmplgen").get_type().unwrap().get_info().unwrap().generate().unwrap();
let mut file = File::create("./template").unwrap();
file.write_all(template.inner.as_bytes()).unwrap();
Wait. What? Here’s a step-by-step example:
use libtmplgen::*;
use std::fs::File;
use std::io::prelude::*;
// Creates a new TmplBuilder for the pkg "tmplgen"
let mut tmpl_builder = TmplBuilder::new("tmplgen");
// Get the PkgType of this crate
tmpl_builder.get_type().unwrap();
// Get a PkgInfo struct of this crate
tmpl_builder.get_info().unwrap();
// Generate a [Template](crate::types::Template) which we can write later on
let template = tmpl_builder.generate().unwrap();
// Create a file called "template" in the current dir
let mut file = File::create("./template").unwrap();
// Write the [Template](crate::types::Template) to the file we just created
file.write_all(template.inner.as_bytes()).unwrap();
See TmplBuilder for most of the exciting other stuff.