feat(module): Add sudo module (#3135)

* add feature - sudo module

* add sudo module identifiers and entry point

* fix test test_sudo_not_cached

* add test test_sudo_cached

* add `allow_windows` and `binary` options

* rustfmt sudo_x_cached and rmv them on windows

* add false `allow_windows` block windows test

* add `doas` cached/not_cached tests

* better description in `starship explain`

* fix `test_doas_cached` with `-n` flag

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* rmv `binary` alternatives and their tests

* fix symbol and update config/README

* fix all mocks to use `sudo -n true`

* fix expected output in `test_sudo_cached`

* proper checking for blocked sudo

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* add `allow_windows = true` to non-windows tests

* allow sudo_* tests to run on windows + fix parsed

* rustfmt `blocks_windows` test

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
This commit is contained in:
Gabriel Victor
2021-11-15 02:46:13 -03:00
committed by GitHub
parent c3e33ea1c7
commit 779e53cd66
8 changed files with 205 additions and 0 deletions
+53
View File
@@ -243,6 +243,7 @@ $openstack\
$env_var\
$crystal\
$custom\
$sudo\
$cmd_duration\
$line_break\
$jobs\
@@ -2947,6 +2948,58 @@ disabled = false
```
## Sudo
The `sudo` module displays if sudo credentials are currently cached.
The module will only be shown if credentials are cached.
::: tip
This module is disabled by default.
To enable it, set `disabled` to `false` in your configuration file.
:::
### Options
| Option | Default | Description |
| -------------- | ----------------------- | ------------------------------------------------------------ |
| `format` | `[as $symbol]($style)"` | The format of the module |
| `symbol` | `"🧙 "` | The symbol displayed when credentials are cached |
| `style` | `"bold blue"` | The style for the module. |
| `allow_windows`| `false` | Since windows has no default sudo, default is disabled. |
| `disabled` | `true` | Disables the `sudo` module. |
### Variables
| Variable | Example | Description |
| --------- | ------- | ------------------------------------ |
| 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
[sudo]
style = "bold green"
symbol = "👩‍💻 "
disabled = false
```
```toml
# On windows
# $HOME\.starship\config.toml
[sudo]
allow_windows = true
disabled = false
```
## Swift
By default the `swift` module shows the currently installed version of [Swift](https://swift.org/).