Skip to content

Commit

Permalink
feat(fossil_branch): add fossil_branch module (#4806)
Browse files Browse the repository at this point in the history
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
  • Loading branch information
VegardSkui and davidkna committed Jan 31, 2023
1 parent 3d76a98 commit 41eb98b
Show file tree
Hide file tree
Showing 13 changed files with 367 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/config-schema.json
Expand Up @@ -504,6 +504,21 @@
}
]
},
"fossil_branch": {
"default": {
"disabled": true,
"format": "on [$symbol$branch]($style) ",
"style": "bold purple",
"symbol": "",
"truncation_length": 9223372036854775807,
"truncation_symbol": ""
},
"allOf": [
{
"$ref": "#/definitions/FossilBranchConfig"
}
]
},
"gcloud": {
"default": {
"disabled": false,
Expand Down Expand Up @@ -2981,6 +2996,37 @@
},
"additionalProperties": false
},
"FossilBranchConfig": {
"type": "object",
"properties": {
"format": {
"default": "on [$symbol$branch]($style) ",
"type": "string"
},
"symbol": {
"default": "",
"type": "string"
},
"style": {
"default": "bold purple",
"type": "string"
},
"truncation_length": {
"default": 9223372036854775807,
"type": "integer",
"format": "int64"
},
"truncation_symbol": {
"default": "",
"type": "string"
},
"disabled": {
"default": true,
"type": "boolean"
}
},
"additionalProperties": false
},
"GcloudConfig": {
"type": "object",
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/public/presets/toml/bracketed-segments.toml
Expand Up @@ -49,6 +49,9 @@ format = '\[[$symbol($version)]($style)\]'
[fennel]
format = '\[[$symbol($version)]($style)\]'

[fossil_branch]
format = '\[[$symbol$branch]($style)\]'

[gcloud]
format = '\[[$symbol$account(@$domain)(\($region\))]($style)\]'

Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/public/presets/toml/nerd-font-symbols.toml
Expand Up @@ -25,6 +25,9 @@ symbol = " "
[elm]
symbol = ""

[fossil_branch]
symbol = ""

[git_branch]
symbol = ""

Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/public/presets/toml/plain-text-symbols.toml
Expand Up @@ -61,6 +61,9 @@ symbol = "elm "
[fennel]
symbol = "fnl "

[fossil_branch]
symbol = "fossil "

[git_branch]
symbol = "git "

Expand Down
37 changes: 37 additions & 0 deletions docs/config/README.md
Expand Up @@ -265,6 +265,7 @@ $singularity\
$kubernetes\
$directory\
$vcsh\
$fossil_branch\
$git_branch\
$git_commit\
$git_state\
Expand Down Expand Up @@ -1556,6 +1557,42 @@ Produces a prompt that looks like:
AA -------------------------------------------- BB -------------------------------------------- CC
```

## Fossil Branch

The `fossil_branch` module shows the name of the active branch of the check-out in your current directory.

### Options

| Option | Default | Description |
| ------------------- | -------------------------------- | ---------------------------------------------------------------------------------------- |
| `format` | `'on [$symbol$branch]($style) '` | The format for the module. Use `'$branch'` to refer to the current branch name. |
| `symbol` | `' '` | The symbol used before the branch name of the check-out in your current directory. |
| `style` | `'bold purple'` | The style for the module. |
| `truncation_length` | `2^63 - 1` | Truncates a Fossil branch name to `N` graphemes |
| `truncation_symbol` | `'…'` | The symbol used to indicate a branch name was truncated. You can use `''` for no symbol. |
| `disabled` | `true` | Disables the `fossil_branch` module. |

### Variables

| Variable | Example | Description |
| -------- | ------- | ------------------------------------ |
| branch | `trunk` | The active Fossil branch |
| symbol | | Mirrors the value of option `symbol` |
| style\* | | Mirrors the value of option `style` |

*: This variable can only be used as a part of a style string

### Example

```toml
# ~/.config/starship.toml

[fossil_branch]
symbol = '🦎 '
truncation_length = 4
truncation_symbol = ''
```

## Google Cloud (`gcloud`)

The `gcloud` module shows the current configuration for [`gcloud`](https://cloud.google.com/sdk/gcloud) CLI.
Expand Down
30 changes: 30 additions & 0 deletions src/configs/fossil_branch.rs
@@ -0,0 +1,30 @@
use serde::{Deserialize, Serialize};

#[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(
feature = "config-schema",
derive(schemars::JsonSchema),
schemars(deny_unknown_fields)
)]
#[serde(default)]
pub struct FossilBranchConfig<'a> {
pub format: &'a str,
pub symbol: &'a str,
pub style: &'a str,
pub truncation_length: i64,
pub truncation_symbol: &'a str,
pub disabled: bool,
}

impl<'a> Default for FossilBranchConfig<'a> {
fn default() -> Self {
FossilBranchConfig {
format: "on [$symbol$branch]($style) ",
symbol: " ",
style: "bold purple",
truncation_length: std::i64::MAX,
truncation_symbol: "…",
disabled: true,
}
}
}
3 changes: 3 additions & 0 deletions src/configs/mod.rs
Expand Up @@ -27,6 +27,7 @@ pub mod env_var;
pub mod erlang;
pub mod fennel;
pub mod fill;
pub mod fossil_branch;
pub mod gcloud;
pub mod git_branch;
pub mod git_commit;
Expand Down Expand Up @@ -155,6 +156,8 @@ pub struct FullConfig<'a> {
#[serde(borrow)]
fill: fill::FillConfig<'a>,
#[serde(borrow)]
fossil_branch: fossil_branch::FossilBranchConfig<'a>,
#[serde(borrow)]
gcloud: gcloud::GcloudConfig<'a>,
#[serde(borrow)]
git_branch: git_branch::GitBranchConfig<'a>,
Expand Down
1 change: 1 addition & 0 deletions src/configs/starship_root.rs
Expand Up @@ -38,6 +38,7 @@ pub const PROMPT_ORDER: &[&str] = &[
"kubernetes",
"directory",
"vcsh",
"fossil_branch",
"git_branch",
"git_commit",
"git_state",
Expand Down
1 change: 1 addition & 0 deletions src/module.rs
Expand Up @@ -34,6 +34,7 @@ pub const ALL_MODULES: &[&str] = &[
"erlang",
"fennel",
"fill",
"fossil_branch",
"gcloud",
"git_branch",
"git_commit",
Expand Down

0 comments on commit 41eb98b

Please sign in to comment.