mirror of
https://github.com/starship/starship.git
synced 2024-11-23 16:53:23 +01:00
022e0002e4
* Create "context" to contain run details * Use context in tests and benchmarks
27 lines
692 B
Rust
27 lines
692 B
Rust
use clap::{App, Arg};
|
|
use starship::context::Context;
|
|
use starship::modules;
|
|
use std::path::PathBuf;
|
|
|
|
pub fn render_segment<T>(module: &str, path: T) -> String
|
|
where
|
|
T: Into<PathBuf>,
|
|
{
|
|
render_segment_with_status(module, &path.into(), "0")
|
|
}
|
|
|
|
pub fn render_segment_with_status<T>(module: &str, path: T, status: &str) -> String
|
|
where
|
|
T: Into<PathBuf>,
|
|
{
|
|
// Create an `Arg` with status_code of "0"
|
|
let args = App::new("starship")
|
|
.arg(Arg::with_name("status_code"))
|
|
.get_matches_from(vec!["starship", status]);
|
|
let context = Context::new_with_dir(args, path.into());
|
|
|
|
let segment = modules::handle(module, &context);
|
|
|
|
segment.unwrap().output()
|
|
}
|