Skip to content

Commit

Permalink
feat: add Haxe support (#4395)
Browse files Browse the repository at this point in the history
* Add Haxe support

* avoid unwrap

* fix doc formatting

* removed extra newline

* fixed formatter and linter issues

* fixed config file

* better version of detecting contents of .haxerc

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

* removed openfl related defaults from detect_files

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

* fixed formatting

* reworked reading .haxerc with fallback to haxe --version

* fixed formatting

* added fallback to executable for dev paths in .haxerc

* fixed linter issue

* added support for Windows paths

* use or_else

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

* use shorter version with `?`

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

* simplified regex check

removed check for "null" string

* fixed format

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
  • Loading branch information
AlexHaxe and davidkna committed Dec 4, 2022
1 parent ef83e7a commit 2766c78
Show file tree
Hide file tree
Showing 11 changed files with 492 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/config-schema.json
Expand Up @@ -658,6 +658,33 @@
}
]
},
"haxe": {
"default": {
"detect_extensions": [
"hx",
"hxml"
],
"detect_files": [
"haxelib.json",
"hxformat.json",
".haxerc"
],
"detect_folders": [
".haxelib",
"haxe_libraries"
],
"disabled": false,
"format": "via [$symbol($version )]($style)",
"style": "bold fg:202",
"symbol": "",
"version_format": "v${raw}"
},
"allOf": [
{
"$ref": "#/definitions/HaxeConfig"
}
]
},
"helm": {
"default": {
"detect_extensions": [],
Expand Down Expand Up @@ -3238,6 +3265,63 @@
},
"additionalProperties": false
},
"HaxeConfig": {
"type": "object",
"properties": {
"format": {
"default": "via [$symbol($version )]($style)",
"type": "string"
},
"version_format": {
"default": "v${raw}",
"type": "string"
},
"symbol": {
"default": "",
"type": "string"
},
"style": {
"default": "bold fg:202",
"type": "string"
},
"disabled": {
"default": false,
"type": "boolean"
},
"detect_extensions": {
"default": [
"hx",
"hxml"
],
"type": "array",
"items": {
"type": "string"
}
},
"detect_files": {
"default": [
"haxelib.json",
"hxformat.json",
".haxerc"
],
"type": "array",
"items": {
"type": "string"
}
},
"detect_folders": {
"default": [
".haxelib",
"haxe_libraries"
],
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
},
"HelmConfig": {
"type": "object",
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/public/presets/toml/bracketed-segments.toml
Expand Up @@ -64,6 +64,9 @@ format = '\[[$symbol]($style)\]'
[haskell]
format = '\[[$symbol($version)]($style)\]'

[haxe]
format = '\[[$symbol($version)]($style)\]'

[helm]
format = '\[[$symbol($version)]($style)\]'

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

[haxe]
symbol = ""

[hg_branch]
symbol = ""

Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/public/presets/toml/no-runtime-versions.toml
Expand Up @@ -37,6 +37,9 @@ format = 'via [$symbol]($style)'
[golang]
format = 'via [$symbol]($style)'

[haxe]
format = 'via [$symbol]($style)'

[helm]
format = 'via [$symbol]($style)'

Expand Down
42 changes: 42 additions & 0 deletions docs/config/README.md
Expand Up @@ -286,6 +286,7 @@ $erlang\
$golang\
$guix_shell\
$haskell\
$haxe\
$helm\
$java\
$julia\
Expand Down Expand Up @@ -1959,6 +1960,47 @@ By default the module will be shown if any of the following conditions are met:

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

## Haxe

The `haxe` module shows the currently installed version of [Haxe](https://haxe.org/).
By default the module will be shown if any of the following conditions are met:

- The current directory contains a `project.xml`, `Project.xml`, `application.xml`, `haxelib.json`, `hxformat.json` or `.haxerc` file
- The current directory contains a `.haxelib` or a `haxe_libraries` directory
- The current directory contains a file with the `.hx` or `.hxml` 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` | `["hx", "hxml"]` | Which extensions should trigger this module. |
| `detect_files` | `["project.xml", "Project.xml", "application.xml", "haxelib.json", "hxformat.json", ".haxerc"]` | Which filenames should trigger this module. |
| `detect_folders` | `[".haxelib", "haxe_libraries"]` | Which folders should trigger this modules. |
| `symbol` | `"⌘ "` | A format string representing the symbol of Helm. |
| `style` | `"bold fg:202"` | The style for the module. |
| `disabled` | `false` | Disables the `haxe` module. |

### Variables

| Variable | Example | Description |
| -------- | -------- | ------------------------------------ |
| version | `v4.2.5` | The version of `haxe` |
| 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

[haxe]
format = "via [⌘ $version](bold fg:202) "
```

## Helm

The `helm` module shows the currently installed version of [Helm](https://helm.sh/).
Expand Down
34 changes: 34 additions & 0 deletions src/configs/haxe.rs
@@ -0,0 +1,34 @@
use serde::{Deserialize, Serialize};

#[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(
feature = "config-schema",
derive(schemars::JsonSchema),
schemars(deny_unknown_fields)
)]
#[serde(default)]
pub struct HaxeConfig<'a> {
pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str,
pub style: &'a str,
pub disabled: bool,
pub detect_extensions: Vec<&'a str>,
pub detect_files: Vec<&'a str>,
pub detect_folders: Vec<&'a str>,
}

impl<'a> Default for HaxeConfig<'a> {
fn default() -> Self {
HaxeConfig {
format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "⌘ ",
style: "bold fg:202",
disabled: false,
detect_extensions: vec!["hx", "hxml"],
detect_files: vec!["haxelib.json", "hxformat.json", ".haxerc"],
detect_folders: vec![".haxelib", "haxe_libraries"],
}
}
}
3 changes: 3 additions & 0 deletions src/configs/mod.rs
Expand Up @@ -35,6 +35,7 @@ pub mod git_status;
pub mod go;
pub mod guix_shell;
pub mod haskell;
pub mod haxe;
pub mod helm;
pub mod hg_branch;
pub mod hostname;
Expand Down Expand Up @@ -167,6 +168,8 @@ pub struct FullConfig<'a> {
#[serde(borrow)]
haskell: haskell::HaskellConfig<'a>,
#[serde(borrow)]
haxe: haxe::HaxeConfig<'a>,
#[serde(borrow)]
helm: helm::HelmConfig<'a>,
#[serde(borrow)]
hg_branch: hg_branch::HgBranchConfig<'a>,
Expand Down
1 change: 1 addition & 0 deletions src/configs/starship_root.rs
Expand Up @@ -59,6 +59,7 @@ pub const PROMPT_ORDER: &[&str] = &[
"erlang",
"golang",
"haskell",
"haxe",
"helm",
"java",
"julia",
Expand Down
1 change: 1 addition & 0 deletions src/module.rs
Expand Up @@ -43,6 +43,7 @@ pub const ALL_MODULES: &[&str] = &[
"golang",
"guix_shell",
"haskell",
"haxe",
"helm",
"hg_branch",
"hostname",
Expand Down

0 comments on commit 2766c78

Please sign in to comment.