From 5caabc0adeba69ec09c44cf9c4a110e7fc50fc6b Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 14 Sep 2022 12:13:31 +0100 Subject: [PATCH] doc: rustdoc for `aliased_command` --- src/bin/cargo/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index 341b2c42d63..e6fb71dd95d 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -53,6 +53,14 @@ fn builtin_aliases_execs(cmd: &str) -> Option<&(&str, &str, &str)> { BUILTIN_ALIASES.iter().find(|alias| alias.0 == cmd) } +/// Resolve the aliased command from the [`Config`] with a given command string. +/// +/// The search fallback chain is: +/// +/// 1. Get the aliased command as a string. +/// 2. If an `Err` occurs (missing key, type mismatch, or any possible error), +/// try to get it as an array again. +/// 3. If still cannot find any, finds one insides [`BUILTIN_ALIASES`]. fn aliased_command(config: &Config, command: &str) -> CargoResult>> { let alias_name = format!("alias.{}", command); let user_alias = match config.get_string(&alias_name) {