feat: Add a module for C projects (#3631)

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
This commit is contained in:
David Cantrell
2022-03-25 04:10:19 +00:00
committed by GitHub
parent b90d1164f5
commit 0863146f07
12 changed files with 371 additions and 0 deletions
+49
View File
@@ -207,6 +207,7 @@ $hg_branch\
$docker_context\
$package\
$buf\
$c\
$cmake\
$cobol\
$container\
@@ -496,6 +497,54 @@ The `buf` module shows the currently installed version of [Buf](https://buf.buil
symbol = "🦬 "
```
## C
The `c` module shows some information about your C compiler. By default
the module will be shown if the current directory contains a `.c` or `.h`
file.
### Options
| Option | Default | Description |
| ------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version(-$name) )]($style)"` | The format string for the module. |
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `symbol` | `"C "` | The symbol used before displaying the compiler details |
| `detect_extensions` | `["c", "h"]` | Which extensions should trigger this module. |
| `detect_files` | `[]` | Which filenames should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. |
| `commands` | [ [ "cc", "--version" ], [ "gcc", "--version" ], [ "clang", "--version" ] ] | How to detect what the compiler is |
| `style` | `"bold 149"` | The style for the module. |
| `disabled` | `false` | Disables the `c` module. |
### Variables
| Variable | Example | Description |
| -------- | ------- | ------------------------------------ |
| name | clang | The name of the compiler |
| version | 13.0.0 | The version of the compiler |
| symbol | | Mirrors the value of option `symbol` |
| style | | Mirrors the value of option `style` |
NB that `version` is not in the default format.
### Commands
The `commands` option accepts a list of commands to determine the compiler version and name.
Each command is represented as a list of the executable name, followed by its arguments, usually something like `["mycc", "--version"]`. Starship will try executing each command until it gets a result on STDOUT.
If a C compiler is not supported by this module, you can request it by [raising an issue on GitHub](https://github.com/starship/starship/).
### Example
```toml
# ~/.config/starship.toml
[c]
format = "via [$name $version]($style)"
```
## Character
The `character` module shows a character (usually an arrow) beside where the text