mirror of
https://github.com/starship/starship.git
synced 2024-12-15 11:50:48 +01:00
Merge branch 'master' into conditional-style
This commit is contained in:
commit
2688af4d1b
28
Cargo.lock
generated
28
Cargo.lock
generated
@ -323,36 +323,35 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.2.22"
|
||||
version = "4.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"
|
||||
checksum = "7f78ad8e84aa8e8aa3e821857be40eb4b925ff232de430d4dd2ae6aa058cbd92"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"once_cell",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
"unicase",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "3.2.5"
|
||||
version = "4.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8"
|
||||
checksum = "11cba7abac9b56dfe2f035098cdb3a43946f276e6db83b72c4e692343f9aab9a"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.2.18"
|
||||
version = "4.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
|
||||
checksum = "ca689d7434ce44517a12a89456b2be4d1ea1cafcd8f581978c03d45f5a5c12a7"
|
||||
dependencies = [
|
||||
"heck 0.4.0",
|
||||
"proc-macro-error",
|
||||
@ -363,9 +362,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.4"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
@ -2997,15 +2996,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.35"
|
||||
|
@ -23,7 +23,7 @@ license = "ISC"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/starship/starship"
|
||||
# Note: MSRV is only intended as a hint, and only the latest version is officially supported in starship.
|
||||
rust-version = "1.59"
|
||||
rust-version = "1.60"
|
||||
description = """
|
||||
The minimal, blazing-fast, and infinitely customizable prompt for any shell! ☄🌌️
|
||||
"""
|
||||
@ -36,8 +36,8 @@ notify = ["notify-rust"]
|
||||
|
||||
[dependencies]
|
||||
chrono = { version = "0.4.22", features = ["clock", "std"] }
|
||||
clap = { version = "=3.2.22", features = ["derive", "cargo", "unicode", "unstable-v4"] }
|
||||
clap_complete = "3.2.5"
|
||||
clap = { version = "4.0.4", features = ["derive", "cargo", "unicode"] }
|
||||
clap_complete = "4.0.2"
|
||||
dirs-next = "2.0.0"
|
||||
dunce = "1.0.2"
|
||||
gethostname = "0.2.3"
|
||||
|
@ -220,7 +220,6 @@ Alternatively, install Starship using any of the following package managers:
|
||||
| Arch Linux | [Arch Linux Community] | `pacman -S starship` |
|
||||
| CentOS 7+ | [Copr] | `dnf copr enable atim/starship` <br /> `dnf install starship` |
|
||||
| Fedora 31+ | [Fedora Packages] | `dnf install starship` |
|
||||
| NixOS | [nixpkgs] | `nix-env -iA nixos.starship` |
|
||||
| Gentoo | [Gentoo Packages] | `emerge app-shells/starship` |
|
||||
| Manjaro | | `pacman -S starship` |
|
||||
| NixOS | [nixpkgs] | `nix-env -iA nixpkgs.starship` |
|
||||
|
@ -1952,21 +1952,21 @@ disabled = false
|
||||
The `java` module shows the currently installed version of [Java](https://www.oracle.com/java/).
|
||||
By default the module will be shown if any of the following conditions are met:
|
||||
|
||||
- The current directory contains a `pom.xml`, `build.gradle.kts`, `build.sbt`, `.java-version`, `.deps.edn`, `project.clj`, or `build.boot` file
|
||||
- The current directory contains a `pom.xml`, `build.gradle.kts`, `build.sbt`, `.java-version`, `deps.edn`, `project.clj`, or `build.boot` file
|
||||
- The current directory contains a file with the `.java`, `.class`, `.gradle`, `.jar`, `.clj`, or `.cljc` extension
|
||||
|
||||
### Options
|
||||
|
||||
| Option | Default | Description |
|
||||
| ------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
||||
| `format` | `"via [${symbol}(${version} )]($style)"` | The format for the module. |
|
||||
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
|
||||
| `detect_extensions` | `["java", "class", "gradle", "jar", "cljs", "cljc"]` | Which extensions should trigger this module. |
|
||||
| `detect_files` | `["pom.xml", "build.gradle.kts", "build.sbt", ".java-version", ".deps.edn", "project.clj", "build.boot"]` | Which filenames should trigger this module. |
|
||||
| `detect_folders` | `[]` | Which folders should trigger this modules. |
|
||||
| `symbol` | `"☕ "` | A format string representing the symbol of Java |
|
||||
| `style` | `"red dimmed"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `java` module. |
|
||||
| Option | Default | Description |
|
||||
| ------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
||||
| `format` | `"via [${symbol}(${version} )]($style)"` | The format for the module. |
|
||||
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
|
||||
| `detect_extensions` | `["java", "class", "gradle", "jar", "cljs", "cljc"]` | Which extensions should trigger this module. |
|
||||
| `detect_files` | `["pom.xml", "build.gradle.kts", "build.sbt", ".java-version", "deps.edn", "project.clj", "build.boot"]` | Which filenames should trigger this module. |
|
||||
| `detect_folders` | `[]` | Which folders should trigger this modules. |
|
||||
| `symbol` | `"☕ "` | A format string representing the symbol of Java |
|
||||
| `style` | `"red dimmed"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `java` module. |
|
||||
|
||||
### Variables
|
||||
|
||||
|
@ -5,7 +5,7 @@ use std::io;
|
||||
use std::thread::available_parallelism;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use clap::{IntoApp, Parser, Subcommand};
|
||||
use clap::{CommandFactory, Parser, Subcommand};
|
||||
use clap_complete::{generate, Shell as CompletionShell};
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::Rng;
|
||||
@ -33,7 +33,7 @@ enum Commands {
|
||||
BugReport,
|
||||
/// Generate starship shell completions for your shell to stdout
|
||||
Completions {
|
||||
#[clap(arg_enum)]
|
||||
#[clap(value_enum)]
|
||||
shell: CompletionShell,
|
||||
},
|
||||
/// Edit the starship configuration
|
||||
|
@ -112,7 +112,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
|| ((num_segments_after_root - 1) as i64) < config.truncation_length
|
||||
{
|
||||
let root = repo_path_vec[0];
|
||||
let before = dir_string.replace(&contracted_path, "");
|
||||
let before = before_root_dir(&dir_string, &contracted_path);
|
||||
[prefix + before.as_str(), root.to_string(), after_repo_root]
|
||||
} else {
|
||||
["".to_string(), "".to_string(), prefix + dir_string.as_str()]
|
||||
@ -341,6 +341,14 @@ fn convert_path_sep(path: &str) -> String {
|
||||
return PathBuf::from_slash(path).to_string_lossy().into_owned();
|
||||
}
|
||||
|
||||
/// Get the path before the git repo root by trim the most right repo name.
|
||||
fn before_root_dir(path: &str, repo: &str) -> String {
|
||||
match path.rsplit_once(repo) {
|
||||
Some((a, _)) => a.to_string(),
|
||||
None => path.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@ -1790,4 +1798,22 @@ mod tests {
|
||||
assert_eq!(expected, actual);
|
||||
tmp_dir.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parent_and_sub_git_repo_are_in_same_name_folder() {
|
||||
assert_eq!(
|
||||
before_root_dir("~/user/gitrepo/gitrepo", "gitrepo"),
|
||||
"~/user/gitrepo/".to_string()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
before_root_dir("~/user/gitrepo-diff/gitrepo", "gitrepo"),
|
||||
"~/user/gitrepo-diff/".to_string()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
before_root_dir("~/user/gitrepo-diff/gitrepo", "aaa"),
|
||||
"~/user/gitrepo-diff/gitrepo".to_string()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use clap::{PossibleValue, ValueEnum};
|
||||
use clap::{builder::PossibleValue, ValueEnum};
|
||||
use nu_ansi_term::AnsiStrings;
|
||||
use rayon::prelude::*;
|
||||
use std::collections::BTreeSet;
|
||||
@ -460,7 +460,7 @@ impl ValueEnum for Preset {
|
||||
shadow::get_preset_list()
|
||||
}
|
||||
|
||||
fn to_possible_value<'a>(&self) -> Option<clap::PossibleValue<'a>> {
|
||||
fn to_possible_value(&self) -> Option<PossibleValue> {
|
||||
Some(PossibleValue::new(self.0))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user