Struct Bootstrap

Source
pub struct Bootstrap { /* private fields */ }
Expand description

a command installer

Implementations§

Source§

impl Bootstrap

Source

pub fn new<P: AsRef<OsStr>>(name: &str, cli: Command, outdir: P) -> Self

Source

pub fn completions(&self) -> Result<(), Box<dyn Error>>

Generates and installs shell completions for all supported shells into dir.

§Examples

To install shell completions under /usr:

use package_bootstrap::Bootstrap;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    Bootstrap::new("foo", clap::Command::new("foo"), "/usr")
        .completions()?;
    Ok(())
}

To install into a staging directory for packaging purposes:

use package_bootstrap::Bootstrap;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    Bootstrap::new("foo", clap::Command::new("foo"), "staging/usr")
        .completions()?;
    Ok(())
}
Source

pub fn translations<P: AsRef<Path>>( &self, podir: P, ) -> Result<(), Box<dyn Error>>

Compiles and installs translations into /share/locale using the msgfmt external utility.

Source

pub fn docfiles<P: AsRef<Path> + AsRef<OsStr>>( &self, files: &[P], doc_subdir: &Path, ) -> Result<(), Box<dyn Error>>

Copies a slice of files to a documentation subdirectory.

§Example

Copy this crate’s README and LICENSE files into /share/doc/foo

use package_bootstrap::Bootstrap;
use std::error::Error;
use std::path::Path;

fn main() -> Result<(), Box<dyn Error>> {
    Bootstrap::new("foo", clap::Command::new("foo"), "pkg/usr")
        .docfiles(&["README.md", "LICENSE.md"], &Path::new("foo"))?;
    Ok(())
}
Source

pub fn install(&self, target_dir: Option<String>) -> Result<(), Box<dyn Error>>

Installs this crate’s binary into /bin. If the “mangen” feature is enabled, also generates and installs the program’s manpage.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.