- Aide facon Nushell : help <cmd>, <cmd> -h/--help, help, help commands, help --find <texte>, help <agent> (fiche info) - sections Usage/Flags/ Command Type/Parameters/Input-output/Examples avec couleurs - Commande version : tableau Nushell (commit, build, rustc, theme...) + --json ; build.rs pour commit/branche git ; -V reste la version courte - Themes : --theme <nom> (default, ocean, sunset, forest, dracula, mono) + settings.theme dans la config ; activation VT Windows pour les couleurs - Cadres blancs Nushell partages : list, search, status, doctor, ls/ps/ where/get et menu d autocompletion Tab encadre (colonnes name/description)
33 lines
1.0 KiB
Rust
33 lines
1.0 KiB
Rust
//! Record build metadata (git commit and branch) at compile time so the
|
|
//! 'am version' command can display it, like Nushell's version table.
|
|
//!
|
|
//! When git is unavailable (e.g. building from a source tarball) the values
|
|
//! are simply empty.
|
|
|
|
use std::process::Command;
|
|
|
|
fn git(args: &[&str]) -> String {
|
|
Command::new("git")
|
|
.args(args)
|
|
.output()
|
|
.ok()
|
|
.filter(|o| o.status.success())
|
|
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
|
|
.unwrap_or_default()
|
|
}
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=.git/HEAD");
|
|
println!("cargo:rerun-if-changed=.git/refs/heads");
|
|
let commit = git(&["rev-parse", "HEAD"]);
|
|
let branch = git(&["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
// A detached HEAD reports the literal branch name "HEAD".
|
|
let branch = if branch == "HEAD" {
|
|
String::new()
|
|
} else {
|
|
branch
|
|
};
|
|
println!("cargo:rustc-env=AM_GIT_COMMIT={commit}");
|
|
println!("cargo:rustc-env=AM_GIT_BRANCH={branch}");
|
|
}
|