Skip to content

Commit

Permalink
feat: add pijul_channel module (starship#4765)
Browse files Browse the repository at this point in the history
* feat: Pijul VCS support

* Extra bits needed for new module.

* Format Markdown table.

* Fix lint.

* Don't test Pijul module so thoroughly.

Installing from source is too expensive, and compiled binaries are only
available for Windows (and unofficially as well). Perhaps once Pijul
1.0.0 comes out of beta there will be more binaries available in package
  repos.

* Format!

* Bad rebase, remove Pijul install from workflow.

* Mock Pijul commands for code coverage.

* Make fake .pijul directory in fixture.

* Truly mock `pijul` command.

* Rename module from `pijul` to `pijul_channel`.

* Format!

* Fix config-schema.json.

* Missed changing module name in docs/ folder.
  • Loading branch information
IslandUsurper authored and Indyandie committed Jul 26, 2023
1 parent 3588b81 commit 6458204
Show file tree
Hide file tree
Showing 13 changed files with 348 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/config-schema.json
Expand Up @@ -1215,6 +1215,21 @@
}
]
},
"pijul_channel": {
"default": {
"disabled": true,
"format": "on [$symbol$channel]($style) ",
"style": "bold purple",
"symbol": "",
"truncation_length": 9223372036854775807,
"truncation_symbol": ""
},
"allOf": [
{
"$ref": "#/definitions/PijulConfig"
}
]
},
"pulumi": {
"default": {
"disabled": false,
Expand Down Expand Up @@ -4495,6 +4510,37 @@
},
"additionalProperties": false
},
"PijulConfig": {
"type": "object",
"properties": {
"symbol": {
"default": "",
"type": "string"
},
"style": {
"default": "bold purple",
"type": "string"
},
"format": {
"default": "on [$symbol$channel]($style) ",
"type": "string"
},
"truncation_length": {
"default": 9223372036854775807,
"type": "integer",
"format": "int64"
},
"truncation_symbol": {
"default": "",
"type": "string"
},
"disabled": {
"default": true,
"type": "boolean"
}
},
"additionalProperties": false
},
"PulumiConfig": {
"type": "object",
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/public/presets/toml/bracketed-segments.toml
Expand Up @@ -130,6 +130,9 @@ format = '\[[$symbol($version)]($style)\]'
[php]
format = '\[[$symbol($version)]($style)\]'

[pijul_channel]
format = '\[[$symbol$channel]($style)\]'

[pulumi]
format = '\[[$symbol$stack]($style)\]'

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

[pijul_channel]
symbol = "🪺 "

[python]
symbol = ""

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

[pijul_channel]
symbol = "pijul "

[pulumi]
symbol = "pulumi "

Expand Down
16 changes: 16 additions & 0 deletions docs/config/README.md
Expand Up @@ -271,6 +271,7 @@ $git_state\
$git_metrics\
$git_status\
$hg_branch\
$pijul_channel\
$docker_context\
$package\
$c\
Expand Down Expand Up @@ -3175,6 +3176,21 @@ By default the module will be shown if any of the following conditions are met:
format = 'via [🔹 $version](147 bold) '
```

## Pijul Channel

The `pijul_channel` module shows the active channel of the repo in your current directory.

### Options

| Option | Default | Description |
| ------------------- | --------------------------------- | ------------------------------------------------------------------------------------ |
| `symbol` | `' '` | The symbol used before the pijul channel name of the repo in your current directory. |
| `style` | `'bold purple'` | The style for the module. |
| `format` | `'on [$symbol$channel]($style) '` | The format for the module. |
| `truncation_length` | `2^63 - 1` | Truncates the pijul channel name to `N` graphemes |
| `truncation_symbol` | `'…'` | The symbol used to indicate a branch name was truncated. |
| `disabled` | `true` | Disables the `pijul` module. |

## Pulumi

The `pulumi` module shows the current username, selected [Pulumi Stack](https://www.pulumi.com/docs/intro/concepts/stack/), and version.
Expand Down
3 changes: 3 additions & 0 deletions src/configs/mod.rs
Expand Up @@ -61,6 +61,7 @@ pub mod os;
pub mod package;
pub mod perl;
pub mod php;
pub mod pijul_channel;
pub mod pulumi;
pub mod purescript;
pub mod python;
Expand Down Expand Up @@ -221,6 +222,8 @@ pub struct FullConfig<'a> {
#[serde(borrow)]
php: php::PhpConfig<'a>,
#[serde(borrow)]
pijul_channel: pijul_channel::PijulConfig<'a>,
#[serde(borrow)]
pulumi: pulumi::PulumiConfig<'a>,
#[serde(borrow)]
purescript: purescript::PureScriptConfig<'a>,
Expand Down
30 changes: 30 additions & 0 deletions src/configs/pijul_channel.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 PijulConfig<'a> {
pub symbol: &'a str,
pub style: &'a str,
pub format: &'a str,
pub truncation_length: i64,
pub truncation_symbol: &'a str,
pub disabled: bool,
}

impl<'a> Default for PijulConfig<'a> {
fn default() -> Self {
PijulConfig {
symbol: " ",
style: "bold purple",
format: "on [$symbol$channel]($style) ",
truncation_length: std::i64::MAX,
truncation_symbol: "…",
disabled: true,
}
}
}
1 change: 1 addition & 0 deletions src/configs/starship_root.rs
Expand Up @@ -42,6 +42,7 @@ pub const PROMPT_ORDER: &[&str] = &[
"git_metrics",
"git_status",
"hg_branch",
"pijul_channel",
"docker_context",
"package",
// ↓ Toolchain version modules ↓
Expand Down
1 change: 1 addition & 0 deletions src/module.rs
Expand Up @@ -68,6 +68,7 @@ pub const ALL_MODULES: &[&str] = &[
"package",
"perl",
"php",
"pijul_channel",
"pulumi",
"purescript",
"python",
Expand Down
3 changes: 3 additions & 0 deletions src/modules/mod.rs
Expand Up @@ -58,6 +58,7 @@ mod os;
mod package;
mod perl;
mod php;
mod pijul_channel;
mod pulumi;
mod purescript;
mod python;
Expand Down Expand Up @@ -159,6 +160,7 @@ pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> {
"package" => package::module(context),
"perl" => perl::module(context),
"php" => php::module(context),
"pijul_channel" => pijul_channel::module(context),
"pulumi" => pulumi::module(context),
"purescript" => purescript::module(context),
"python" => python::module(context),
Expand Down Expand Up @@ -273,6 +275,7 @@ pub fn description(module: &str) -> &'static str {
"package" => "The package version of the current directory's project",
"perl" => "The currently installed version of Perl",
"php" => "The currently installed version of PHP",
"pijul_channel" => "The current channel of the repo in the current directory",
"pulumi" => "The current username, stack, and installed version of Pulumi",
"purescript" => "The currently installed version of PureScript",
"python" => "The currently installed version of Python",
Expand Down

0 comments on commit 6458204

Please sign in to comment.