1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-09-22 18:59:02 +00:00

feat: Add version formating for modules (#2611)

* format crystal version with VersionFormatter

* update crystal dosc

* format crystal module

* fix typos

* format dart version with VersionFormatter

* fix dart malformed test

* update dart docs

* format cmake version with VersionFormatter

* update cmake docs

* format deno version with VersionFormatter

* update deno docs

* remove Version type

* format dotnet version with VersionFormatter

* update dotnet docs

* format erlang version with VersionFormatter

* update erlang docs

* format golang version with VersionFormatter

* refactor formatting in my modules

* format helm version with VersionFormatter

* format julia version with VersionFormatter

* format kotlin version with VersionFormatter

* format lua version with VersionFormatter

* format nim version with VersionFormatter

* format perl version with VersionFormatter

* format php version with VersionFormatter

* format purescript version with VersionFormatter

* format scala version with VersionFormatter

* format swift version with VersionFormatter

* format terraform version with VersionFormatter

* format vagrant version with VersionFormatter

* format zig version with VersionFormatter

* format elixir version with VersionFormatter

* format ocaml version with VersionFormatter

* update elixir docs

* update golang docs

* update helm docs

* update julia docs

* update kotlin docs

* update lua docs

* update nim docs

* update ocaml docs

* update perl docs

* update php docs

* update purescript docs

* update scala docs

* update swift docs

* update terraform docs

* update vagrant docs

* update zig docs

* format elm version with VersionFormatter

* update elm docs

* pass module_name as &str to format_module_version
This commit is contained in:
filip 2021-04-29 23:22:20 +02:00 committed by GitHub
parent c2e84e1802
commit 540c2c2475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 601 additions and 414 deletions

View File

@ -466,15 +466,16 @@ the module will be activated if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | -------------------------------------- | -------------------------------------------- | | ------------------- | -------------------------------------- | ------------------------------------------------------------------------ |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"△ "` | The symbol used before the version of cmake. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch`|
| `detect_extensions` | `[]` | Which extensions should trigger this module | | `symbol` | `"△ "` | The symbol used before the version of cmake. |
| `detect_files` | `["CMakeLists.txt", "CMakeCache.txt"]` | Which filenames should trigger this module | | `detect_extensions` | `[]` | Which extensions should trigger this module |
| `detect_folders` | `[]` | Which folders should trigger this module | | `detect_files` | `["CMakeLists.txt", "CMakeCache.txt"]` | Which filenames should trigger this module |
| `style` | `"bold blue"` | The style for the module. | | `detect_folders` | `[]` | Which folders should trigger this module |
| `disabled` | `false` | Disables the `cmake` module. | | `style` | `"bold blue"` | The style for the module. |
| `disabled` | `false` | Disables the `cmake` module. |
### Variables ### Variables
@ -592,15 +593,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | --------------------------------------------------------- | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------ |
| `symbol` | `"🔮 "` | The symbol used before displaying the version of crystal. | | `symbol` | `"🔮 "` | The symbol used before displaying the version of crystal. |
| `style` | `"bold red"` | The style for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `detect_extensions` | `["cr"]` | Which extensions should trigger this module. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch`|
| `detect_files` | `["shard.yml"]` | Which filenames should trigger this module. | | `style` | `"bold red"` | The style for the module. |
| `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_extensions` | `["cr"]` | Which extensions should trigger this module. |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `detect_files` | `["shard.yml"]` | Which filenames should trigger this module. |
| `disabled` | `false` | Disables the `crystal` module. | | `detect_folders` | `[]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `crystal` module. |
### Variables ### Variables
@ -632,15 +634,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------------------- | ----------------------------------------------- | | ------------------- | ------------------------------------------------- | ------------------------------------------------------------------------ |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"🎯 "` | A format string representing the symbol of Dart | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch`|
| `detect_extensions` | `["dart"]` | Which extensions should trigger this module. | | `symbol` | `"🎯 "` | A format string representing the symbol of Dart |
| `detect_files` | `["pubspec.yaml", "pubspec.yml", "pubspec.lock"]` | Which filenames should trigger this module. | | `detect_extensions` | `["dart"]` | Which extensions should trigger this module. |
| `detect_folders` | `[".dart_tool"]` | Which folders should trigger this module. | | `detect_files` | `["pubspec.yaml", "pubspec.yml", "pubspec.lock"]` | Which filenames should trigger this module. |
| `style` | `"bold blue"` | The style for the module. | | `detect_folders` | `[".dart_tool"]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `dart` module. | | `style` | `"bold blue"` | The style for the module. |
| `disabled` | `false` | Disables the `dart` module. |
### Variables ### Variables
@ -669,15 +672,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------------------- | ----------------------------------------------- | | ------------------- | ------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"🦕 "` | A format string representing the symbol of Deno | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `[]` | Which extensions should trigger this module. | | `symbol` | `"🦕 "` | A format string representing the symbol of Deno |
| `detect_files` | `["mod.ts", "mod.js", "deps.ts", "deps.js"]` | Which filenames should trigger this module. | | `detect_extensions` | `[]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_files` | `["mod.ts", "mod.js", "deps.ts", "deps.js"]` | Which filenames should trigger this module. |
| `style` | `"green bold"` | The style for the module. | | `detect_folders` | `[]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `deno` module. | | `style` | `"green bold"` | The style for the module. |
| `disabled` | `false` | Disables the `deno` module. |
### Variables ### Variables
@ -839,16 +843,17 @@ when there is a csproj file in the current directory.
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | | ------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `"[$symbol($version )(🎯 $tfm )]($style)"` | The format for the module. | | `format` | `"[$symbol($version )(🎯 $tfm )]($style)"` | The format for the module. |
| `symbol` | `".NET "` | The symbol used before displaying the version of dotnet. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `heuristic` | `true` | Use faster version detection to keep starship snappy. | | `symbol` | `".NET "` | The symbol used before displaying the version of dotnet. |
| `detect_extensions` | `["sln", "csproj", "fsproj", "xproj"]` | Which extensions should trigger this module. | | `heuristic` | `true` | Use faster version detection to keep starship snappy. |
| `detect_files` | `["global.json", "project.json", "Directory.Build.props", "Directory.Build.targets", "Packages.props"]` | Which filenames should trigger this module. | | `detect_extensions` | `["sln", "csproj", "fsproj", "xproj"]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this modules. | | `detect_files` | `["global.json", "project.json", "Directory.Build.props", "Directory.Build.targets", "Packages.props"]` | Which filenames should trigger this module. |
| `style` | `"bold blue"` | The style for the module. | | `detect_folders` | `[]` | Which folders should trigger this modules. |
| `disabled` | `false` | Disables the `dotnet` module. | | `style` | `"bold blue"` | The style for the module. |
| `disabled` | `false` | Disables the `dotnet` module. |
### Variables ### Variables
@ -881,15 +886,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | --------------------------------------------------------- | --------------------------------------------------------------- | | ------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------- |
| `symbol` | `"💧 "` | The symbol used before displaying the version of Elixir/Erlang. | | `format` | `'via [$symbol($version \(OTP $otp_version\) )]($style)'` | The format for the module elixir. |
| `detect_extensions` | `[]` | Which extensions should trigger this module. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_files` | `["mix.exs"]` | Which filenames should trigger this module. | | `symbol` | `"💧 "` | The symbol used before displaying the version of Elixir/Erlang. |
| `detect_folders` | `[]` | Which folders should trigger this modules. | | `detect_extensions` | `[]` | Which extensions should trigger this module. |
| `style` | `"bold purple"` | The style for the module. | | `detect_files` | `["mix.exs"]` | Which filenames should trigger this module. |
| `format` | `'via [$symbol($version \(OTP $otp_version\) )]($style)'` | The format for the module elixir. | | `detect_folders` | `[]` | Which folders should trigger this modules. |
| `disabled` | `false` | Disables the `elixir` module. | | `style` | `"bold purple"` | The style for the module. |
| `disabled` | `false` | Disables the `elixir` module. |
### Variables ### Variables
@ -924,15 +930,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | -------------------------------------------------- | ----------------------------------------------- | | ------------------- | -------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"🌳 "` | A format string representing the symbol of Elm. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `["elm"]` | Which extensions should trigger this module. | | `symbol` | `"🌳 "` | A format string representing the symbol of Elm. |
| `detect_files` | `["elm.json", "elm-package.json", ".elm-version"]` | Which filenames should trigger this module. | | `detect_extensions` | `["elm"]` | Which extensions should trigger this module. |
| `detect_folders` | `["elm-stuff"]` | Which folders should trigger this modules. | | `detect_files` | `["elm.json", "elm-package.json", ".elm-version"]` | Which filenames should trigger this module. |
| `style` | `"cyan bold"` | The style for the module. | | `detect_folders` | `["elm-stuff"]` | Which folders should trigger this modules. |
| `disabled` | `false` | Disables the `elm` module. | | `style` | `"cyan bold"` | The style for the module. |
| `disabled` | `false` | Disables the `elm` module. |
### Variables ### Variables
@ -1001,15 +1008,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | -------------------------------------------------------- | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `symbol` | `" "` | The symbol used before displaying the version of erlang. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `style` | `"bold red"` | The style for the module. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `[]` | Which extensions should trigger this module. | | `symbol` | `" "` | The symbol used before displaying the version of erlang. |
| `detect_files` | `["rebar.config", "elang.mk"]` | Which filenames should trigger this module. | | `style` | `"bold red"` | The style for the module. |
| `detect_folders` | `[]` | Which folders should trigger this modules. | | `detect_extensions` | `[]` | Which extensions should trigger this module. |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `detect_files` | `["rebar.config", "elang.mk"]` | Which filenames should trigger this module. |
| `disabled` | `false` | Disables the `erlang` module. | | `detect_folders` | `[]` | Which folders should trigger this modules. |
| `disabled` | `false` | Disables the `erlang` module. |
### Variables ### Variables
@ -1309,15 +1317,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| -------------------- | ------------------------------------------------------------------------------ | ---------------------------------------------- | | ------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"🐹 "` | A format string representing the symbol of Go. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `["go"]` | Which extensions should trigger this module. | | `symbol` | `"🐹 "` | A format string representing the symbol of Go. |
| `detect_files` | `["go.mod", "go.sum", "glide.yaml", "Gopkg.yml", "Gopkg.lock", ".go-version"]` | Which filenames should trigger this module. | | `detect_extensions` | `["go"]` | Which extensions should trigger this module. |
| `detect_folders` | `["Godeps"]` | Which folders should trigger this module. | | `detect_files` | `["go.mod", "go.sum", "glide.yaml", "Gopkg.yml", "Gopkg.lock", ".go-version"]` | Which filenames should trigger this module. |
| `style` | `"bold cyan"` | The style for the module. | | `detect_folders` | `["Godeps"]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `golang` module. | | `style` | `"bold cyan"` | The style for the module. |
| `disabled` | `false` | Disables the `golang` module. |
### Variables ### Variables
@ -1348,15 +1357,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | ------------------------------------------------ | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `detect_extensions` | `[]` | Which extensions should trigger this module. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_files` | `["helmfile.yaml", "Chart.yaml"]` | Which filenames should trigger this module. | | `detect_extensions` | `[]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this modules. | | `detect_files` | `["helmfile.yaml", "Chart.yaml"]` | Which filenames should trigger this module. |
| `symbol` | `"⎈ "` | A format string representing the symbol of Helm. | | `detect_folders` | `[]` | Which folders should trigger this modules. |
| `style` | `"bold white"` | The style for the module. | | `symbol` | `"⎈ "` | A format string representing the symbol of Helm. |
| `disabled` | `false` | Disables the `helm` module. | | `style` | `"bold white"` | The style for the module. |
| `disabled` | `false` | Disables the `helm` module. |
### Variables ### Variables
@ -1507,15 +1517,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | ------------------------------------------------- | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `detect_extensions` | `["jl"]` | Which extensions should trigger this module. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_files` | `["Project.toml", "Manifest.toml"]` | Which filenames should trigger this module. | | `detect_extensions` | `["jl"]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this modules. | | `detect_files` | `["Project.toml", "Manifest.toml"]` | Which filenames should trigger this module. |
| `symbol` | `"ஃ "` | A format string representing the symbol of Julia. | | `detect_folders` | `[]` | Which folders should trigger this modules. |
| `style` | `"bold purple"` | The style for the module. | | `symbol` | `"ஃ "` | A format string representing the symbol of Julia. |
| `disabled` | `false` | Disables the `julia` module. | | `style` | `"bold purple"` | The style for the module. |
| `disabled` | `false` | Disables the `julia` module. |
### Variables ### Variables
@ -1548,6 +1559,7 @@ By default the module will be shown if any of the following conditions are met:
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | ----------------------------------------------------------------------------- | | ------------------- | ------------------------------------ | ----------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `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` | `["kt", "kts"]` | Which extensions should trigger this module. | | `detect_extensions` | `["kt", "kts"]` | Which extensions should trigger this module. |
| `detect_files` | `[]` | Which filenames should trigger this module. | | `detect_files` | `[]` | Which filenames should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this modules. | | `detect_folders` | `[]` | Which folders should trigger this modules. |
@ -1663,6 +1675,7 @@ By default the module will be shown if any of the following conditions are met:
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | ----------------------------------------------------------------------------- | | ------------------- | ------------------------------------ | ----------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `symbol` | `"🌙 "` | A format string representing the symbol of Lua. | | `symbol` | `"🌙 "` | A format string representing the symbol of Lua. |
| `detect_extensions` | `["lua"]` | Which extensions should trigger this module. | | `detect_extensions` | `["lua"]` | Which extensions should trigger this module. |
| `detect_files` | `[".lua-version"]` | Which filenames should trigger this module. | | `detect_files` | `[".lua-version"]` | Which filenames should trigger this module. |
@ -1787,15 +1800,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| -------------------- | ------------------------------------ | ----------------------------------------------------- | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module | | `format` | `"via [$symbol($version )]($style)"` | The format for the module |
| `symbol` | `"👑 "` | The symbol used before displaying the version of Nim. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `["nim", "nims", "nimble"]` | Which extensions should trigger this module. | | `symbol` | `"👑 "` | The symbol used before displaying the version of Nim. |
| `detect_files` | `["nim.cfg"]` | Which filenames should trigger this module. | | `detect_extensions` | `["nim", "nims", "nimble"]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_files` | `["nim.cfg"]` | Which filenames should trigger this module. |
| `style` | `"bold yellow"` | The style for the module. | | `detect_folders` | `[]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `nim` module. | | `style` | `"bold yellow"` | The style for the module. |
| `disabled` | `false` | Disables the `nim` module. |
### Variables ### Variables
@ -1915,17 +1929,18 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------- | | ------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )(\($switch_indicator$switch_name\) )]($style)"` | The format string for the module. | | `format` | `"via [$symbol($version )(\($switch_indicator$switch_name\) )]($style)"` | The format string for the module. |
| `symbol` | `"🐫 "` | The symbol used before displaying the version of OCaml. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `global_switch_indicator` | `""` | The format string used to represent global OPAM switch. | | `symbol` | `"🐫 "` | The symbol used before displaying the version of OCaml. |
| `local_switch_indicator` | `"*"` | The format string used to represent local OPAM switch. | | `global_switch_indicator` | `""` | The format string used to represent global OPAM switch. |
| `detect_extensions` | `["opam", "ml", "mli", "re", "rei"]` | Which extensions should trigger this module. | | `local_switch_indicator` | `"*"` | The format string used to represent local OPAM switch. |
| `detect_files` | `["dune", "dune-project", "jbuild", "jbuild-ignore", ".merlin"]` | Which filenames should trigger this module. | | `detect_extensions` | `["opam", "ml", "mli", "re", "rei"]` | Which extensions should trigger this module. |
| `detect_folders` | `["_opam", "esy.lock"]` | Which folders should trigger this module. | | `detect_files` | `["dune", "dune-project", "jbuild", "jbuild-ignore", ".merlin"]` | Which filenames should trigger this module. |
| `style` | `"bold yellow"` | The style for the module. | | `detect_folders` | `["_opam", "esy.lock"]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `ocaml` module. | | `style` | `"bold yellow"` | The style for the module. |
| `disabled` | `false` | Disables the `ocaml` module. |
### Variables ### Variables
@ -2052,15 +2067,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |****
| -------------------- | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | | ------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format string for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format string for the module. |
| `symbol` | `"🐪 "` | The symbol used before displaying the version of Perl | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `["pl", "pm", "pod"]` | Which extensions should trigger this module. | | `symbol` | `"🐪 "` | The symbol used before displaying the version of Perl |
| `detect_files` | `["Makefile.PL", "Build.PL", "cpanfile", "cpanfile.snapshot", "META.json", "META.yml", ".perl-version"]` | Which filenames should trigger this module. | | `detect_extensions` | `["pl", "pm", "pod"]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_files` | `["Makefile.PL", "Build.PL", "cpanfile", "cpanfile.snapshot", "META.json", "META.yml", ".perl-version"]` | Which filenames should trigger this module. |
| `style` | `"bold 149"` | The style for the module. | | `detect_folders` | `[]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `perl` module. | | `style` | `"bold 149"` | The style for the module. |
| `disabled` | `false` | Disables the `perl` module. |
### Variables ### Variables
@ -2090,15 +2106,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| -------------------- | ------------------------------------ | ----------------------------------------------------- | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"🐘 "` | The symbol used before displaying the version of PHP. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `["php"]` | Which extensions should trigger this module. | | `symbol` | `"🐘 "` | The symbol used before displaying the version of PHP. |
| `detect_files` | `["composer.json", ".php-version"]` | Which filenames should trigger this module. | | `detect_extensions` | `["php"]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_files` | `["composer.json", ".php-version"]` | Which filenames should trigger this module. |
| `style` | `"147 bold"` | The style for the module. | | `detect_folders` | `[]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `php` module. | | `style` | `"147 bold"` | The style for the module. |
| `disabled` | `false` | Disables the `php` module. |
### Variables ### Variables
@ -2129,15 +2146,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| -------------------- | ------------------------------------ | ------------------------------------------------------------ | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"<=> "` | The symbol used before displaying the version of PureScript. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `["purs"]` | Which extensions should trigger this module. | | `symbol` | `"<=> "` | The symbol used before displaying the version of PureScript. |
| `detect_files` | `["spago.dhall"]` | Which filenames should trigger this module. | | `detect_extensions` | `["purs"]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_files` | `["spago.dhall"]` | Which filenames should trigger this module. |
| `style` | `"bold white"` | The style for the module. | | `detect_folders` | `[]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `purescript` module. | | `style` | `"bold white"` | The style for the module. |
| `disabled` | `false` | Disables the `purescript` module. |
### Variables ### Variables
@ -2379,15 +2397,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------------- | ------------------------------------------------- | | ------------------- | ---------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `"via [${symbol}(${version} )]($style)"` | The format for the module. | | `format` | `"via [${symbol}(${version} )]($style)"` | The format for the module. |
| `detect_extensions` | `["sbt", "scala"]` | Which extensions should trigger this module. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_files` | `[".scalaenv", ".sbtenv", "build.sbt"]` | Which filenames should trigger this module. | | `detect_extensions` | `["sbt", "scala"]` | Which extensions should trigger this module. |
| `detect_folders` | `[".metals"]` | Which folders should trigger this modules. | | `detect_files` | `[".scalaenv", ".sbtenv", "build.sbt"]` | Which filenames should trigger this module. |
| `symbol` | `"🆂 "` | A format string representing the symbol of Scala. | | `detect_folders` | `[".metals"]` | Which folders should trigger this modules. |
| `style` | `"red dimmed"` | The style for the module. | | `symbol` | `"🆂 "` | A format string representing the symbol of Scala. |
| `disabled` | `false` | Disables the `scala` module. | | `style` | `"red dimmed"` | The style for the module. |
| `disabled` | `false` | Disables the `scala` module. |
### Variables ### Variables
@ -2591,15 +2610,16 @@ The module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | ------------------------------------------------ | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"🐦 "` | A format string representing the symbol of Swift | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `["swift"]` | Which extensions should trigger this module. | | `symbol` | `"🐦 "` | A format string representing the symbol of Swift |
| `detect_files` | `["Package.swift"]` | Which filenames should trigger this module. | | `detect_extensions` | `["swift"]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_files` | `["Package.swift"]` | Which filenames should trigger this module. |
| `style` | `"bold 202"` | The style for the module. | | `detect_folders` | `[]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `swift` module. | | `style` | `"bold 202"` | The style for the module. |
| `disabled` | `false` | Disables the `swift` module. |
### Variables ### Variables
@ -2638,15 +2658,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | ----------------------------------------------------- | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol$workspace]($style) "` | The format string for the module. | | `format` | `"via [$symbol$workspace]($style) "` | The format string for the module. |
| `symbol` | `"💠"` | A format string shown before the Terraform workspace. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `["tf", "hcl"]` | Which extensions should trigger this module. | | `symbol` | `"💠"` | A format string shown before the terraform workspace. |
| `detect_files` | `[]` | Which filenames should trigger this module. | | `detect_extensions` | `["tf", "hcl"]` | Which extensions should trigger this module. |
| `detect_folders` | `[".terraform"]` | Which folders should trigger this module. | | `detect_files` | `[]` | Which filenames should trigger this module. |
| `style` | `"bold 105"` | The style for the module. | | `detect_folders` | `[".terraform"]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `terraform` module. | | `style` | `"bold 105"` | The style for the module. |
| `disabled` | `false` | Disables the `terraform` module. |
### Variables ### Variables
@ -2785,15 +2806,16 @@ By default the module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | --------------------------------------------------- | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"⍱ "` | A format string representing the symbol of Vagrant. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `[]` | Which extensions should trigger this module. | | `symbol` | `"⍱ "` | A format string representing the symbol of Vagrant. |
| `detect_files` | `["Vagrantfile"]` | Which filenames should trigger this module. | | `detect_extensions` | `[]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_files` | `["Vagrantfile"]` | Which filenames should trigger this module. |
| `style` | `"cyan bold"` | The style for the module. | | `detect_folders` | `[]` | Which folders should trigger this module. |
| `disabled` | `false` | Disables the `vagrant` module. | | `style` | `"cyan bold"` | The style for the module. |
| `disabled` | `false` | Disables the `vagrant` module. |
### Variables ### Variables
@ -2856,15 +2878,16 @@ The module will be shown if any of the following conditions are met:
### Options ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------ | ----------------------------------------------------- | | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `symbol` | `"↯ "` | The symbol used before displaying the version of Zig. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `style` | `"bold yellow"` | The style for the module. | | `version_format` | `v{raw}` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `symbol` | `"↯ "` | The symbol used before displaying the version of Zig. |
| `disabled` | `false` | Disables the `zig` module. | | `style` | `"bold yellow"` | The style for the module. |
| `detect_extensions` | `["zig"]` | Which extensions should trigger this module. | | `disabled` | `false` | Disables the `zig` module. |
| `detect_files` | `[]` | Which filenames should trigger this module. | | `detect_extensions` | `["zig"]` | Which extensions should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_files` | `[]` | Which filenames should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. |
### Variables ### Variables

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct CMakeConfig<'a> { pub struct CMakeConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for CMakeConfig<'a> {
fn default() -> Self { fn default() -> Self {
CMakeConfig { CMakeConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "", symbol: "",
style: "bold blue", style: "bold blue",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct CrystalConfig<'a> { pub struct CrystalConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for CrystalConfig<'a> {
fn default() -> Self { fn default() -> Self {
CrystalConfig { CrystalConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🔮 ", symbol: "🔮 ",
style: "bold red", style: "bold red",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct DartConfig<'a> { pub struct DartConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for DartConfig<'a> {
fn default() -> Self { fn default() -> Self {
DartConfig { DartConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🎯 ", symbol: "🎯 ",
style: "bold blue", style: "bold blue",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct DenoConfig<'a> { pub struct DenoConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for DenoConfig<'a> {
fn default() -> Self { fn default() -> Self {
DenoConfig { DenoConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🦕 ", symbol: "🦕 ",
style: "green bold", style: "green bold",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct DotnetConfig<'a> { pub struct DotnetConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub heuristic: bool, pub heuristic: bool,
@ -19,6 +20,7 @@ impl<'a> Default for DotnetConfig<'a> {
fn default() -> Self { fn default() -> Self {
DotnetConfig { DotnetConfig {
format: "[$symbol($version )(🎯 $tfm )]($style)", format: "[$symbol($version )(🎯 $tfm )]($style)",
version_format: "v${raw}",
symbol: ".NET ", symbol: ".NET ",
style: "blue bold", style: "blue bold",
heuristic: true, heuristic: true,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct ElixirConfig<'a> { pub struct ElixirConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for ElixirConfig<'a> {
fn default() -> Self { fn default() -> Self {
ElixirConfig { ElixirConfig {
format: "via [$symbol($version \\(OTP $otp_version\\) )]($style)", format: "via [$symbol($version \\(OTP $otp_version\\) )]($style)",
version_format: "v${raw}",
symbol: "💧 ", symbol: "💧 ",
style: "bold purple", style: "bold purple",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct ElmConfig<'a> { pub struct ElmConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for ElmConfig<'a> {
fn default() -> Self { fn default() -> Self {
ElmConfig { ElmConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🌳 ", symbol: "🌳 ",
style: "cyan bold", style: "cyan bold",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct ErlangConfig<'a> { pub struct ErlangConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for ErlangConfig<'a> {
fn default() -> Self { fn default() -> Self {
ErlangConfig { ErlangConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "", symbol: "",
style: "bold red", style: "bold red",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct GoConfig<'a> { pub struct GoConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for GoConfig<'a> {
fn default() -> Self { fn default() -> Self {
GoConfig { GoConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🐹 ", symbol: "🐹 ",
style: "bold cyan", style: "bold cyan",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct HelmConfig<'a> { pub struct HelmConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for HelmConfig<'a> {
fn default() -> Self { fn default() -> Self {
HelmConfig { HelmConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "", symbol: "",
style: "bold white", style: "bold white",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct JuliaConfig<'a> { pub struct JuliaConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for JuliaConfig<'a> {
fn default() -> Self { fn default() -> Self {
JuliaConfig { JuliaConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "", symbol: "",
style: "bold purple", style: "bold purple",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct KotlinConfig<'a> { pub struct KotlinConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub kotlin_binary: &'a str, pub kotlin_binary: &'a str,
@ -19,6 +20,7 @@ impl<'a> Default for KotlinConfig<'a> {
fn default() -> Self { fn default() -> Self {
KotlinConfig { KotlinConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🅺 ", symbol: "🅺 ",
style: "bold blue", style: "bold blue",
kotlin_binary: "kotlin", kotlin_binary: "kotlin",

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct LuaConfig<'a> { pub struct LuaConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub lua_binary: &'a str, pub lua_binary: &'a str,
@ -19,6 +20,7 @@ impl<'a> Default for LuaConfig<'a> {
fn default() -> Self { fn default() -> Self {
LuaConfig { LuaConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🌙 ", symbol: "🌙 ",
style: "bold blue", style: "bold blue",
lua_binary: "lua", lua_binary: "lua",

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct NimConfig<'a> { pub struct NimConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for NimConfig<'a> {
fn default() -> Self { fn default() -> Self {
NimConfig { NimConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "👑 ", symbol: "👑 ",
style: "yellow bold", style: "yellow bold",
disabled: false, disabled: false,

View File

@ -5,9 +5,10 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct OCamlConfig<'a> { pub struct OCamlConfig<'a> {
pub format: &'a str,
pub version_format: &'a str,
pub global_switch_indicator: &'a str, pub global_switch_indicator: &'a str,
pub local_switch_indicator: &'a str, pub local_switch_indicator: &'a str,
pub format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -19,9 +20,10 @@ pub struct OCamlConfig<'a> {
impl<'a> Default for OCamlConfig<'a> { impl<'a> Default for OCamlConfig<'a> {
fn default() -> Self { fn default() -> Self {
OCamlConfig { OCamlConfig {
format: "via [$symbol($version )(\\($switch_indicator$switch_name\\) )]($style)",
version_format: "v${raw}",
global_switch_indicator: "", global_switch_indicator: "",
local_switch_indicator: "*", local_switch_indicator: "*",
format: "via [$symbol($version )(\\($switch_indicator$switch_name\\) )]($style)",
symbol: "🐫 ", symbol: "🐫 ",
style: "bold yellow", style: "bold yellow",
disabled: false, disabled: false,

View File

@ -5,9 +5,10 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct PerlConfig<'a> { pub struct PerlConfig<'a> {
pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub format: &'a str,
pub disabled: bool, pub disabled: bool,
pub detect_extensions: Vec<&'a str>, pub detect_extensions: Vec<&'a str>,
pub detect_files: Vec<&'a str>, pub detect_files: Vec<&'a str>,
@ -17,9 +18,10 @@ pub struct PerlConfig<'a> {
impl<'a> Default for PerlConfig<'a> { impl<'a> Default for PerlConfig<'a> {
fn default() -> Self { fn default() -> Self {
PerlConfig { PerlConfig {
format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🐪 ", symbol: "🐪 ",
style: "149 bold", style: "149 bold",
format: "via [$symbol($version )]($style)",
disabled: false, disabled: false,
detect_extensions: vec!["pl", "pm", "pod"], detect_extensions: vec!["pl", "pm", "pod"],
detect_files: vec![ detect_files: vec![

View File

@ -5,9 +5,10 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct PhpConfig<'a> { pub struct PhpConfig<'a> {
pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub format: &'a str,
pub disabled: bool, pub disabled: bool,
pub detect_extensions: Vec<&'a str>, pub detect_extensions: Vec<&'a str>,
pub detect_files: Vec<&'a str>, pub detect_files: Vec<&'a str>,
@ -17,9 +18,10 @@ pub struct PhpConfig<'a> {
impl<'a> Default for PhpConfig<'a> { impl<'a> Default for PhpConfig<'a> {
fn default() -> Self { fn default() -> Self {
PhpConfig { PhpConfig {
format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🐘 ", symbol: "🐘 ",
style: "147 bold", style: "147 bold",
format: "via [$symbol($version )]($style)",
disabled: false, disabled: false,
detect_extensions: vec!["php"], detect_extensions: vec!["php"],
detect_files: vec!["composer.json", ".php-version"], detect_files: vec!["composer.json", ".php-version"],

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct PureScriptConfig<'a> { pub struct PureScriptConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for PureScriptConfig<'a> {
fn default() -> Self { fn default() -> Self {
PureScriptConfig { PureScriptConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "<=> ", symbol: "<=> ",
style: "bold white", style: "bold white",
disabled: false, disabled: false,

View File

@ -5,8 +5,9 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct ScalaConfig<'a> { pub struct ScalaConfig<'a> {
pub disabled: bool,
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub disabled: bool,
pub style: &'a str, pub style: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub detect_extensions: Vec<&'a str>, pub detect_extensions: Vec<&'a str>,
@ -18,6 +19,7 @@ impl<'a> Default for ScalaConfig<'a> {
fn default() -> Self { fn default() -> Self {
ScalaConfig { ScalaConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
disabled: false, disabled: false,
style: "red bold", style: "red bold",
symbol: "🆂 ", symbol: "🆂 ",

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct SwiftConfig<'a> { pub struct SwiftConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for SwiftConfig<'a> {
fn default() -> Self { fn default() -> Self {
SwiftConfig { SwiftConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "🐦 ", symbol: "🐦 ",
style: "bold 202", style: "bold 202",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct TerraformConfig<'a> { pub struct TerraformConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for TerraformConfig<'a> {
fn default() -> Self { fn default() -> Self {
TerraformConfig { TerraformConfig {
format: "via [$symbol$workspace]($style) ", format: "via [$symbol$workspace]($style) ",
version_format: "v${raw}",
symbol: "💠 ", symbol: "💠 ",
style: "bold 105", style: "bold 105",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct VagrantConfig<'a> { pub struct VagrantConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for VagrantConfig<'a> {
fn default() -> Self { fn default() -> Self {
VagrantConfig { VagrantConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "", symbol: "",
style: "cyan bold", style: "cyan bold",
disabled: false, disabled: false,

View File

@ -6,6 +6,7 @@ use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct ZigConfig<'a> { pub struct ZigConfig<'a> {
pub format: &'a str, pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,
pub disabled: bool, pub disabled: bool,
@ -18,6 +19,7 @@ impl<'a> Default for ZigConfig<'a> {
fn default() -> Self { fn default() -> Self {
ZigConfig { ZigConfig {
format: "via [$symbol($version )]($style)", format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "", symbol: "",
style: "bold yellow", style: "bold yellow",
disabled: false, disabled: false,

View File

@ -60,6 +60,20 @@ impl<'a> VersionFormatter<'a> {
.collect::<String>() .collect::<String>()
}) })
} }
pub fn format_module_version(
module_name: &str,
version: &str,
version_format: &str,
) -> Option<String> {
match VersionFormatter::format_version(version, version_format) {
Ok(formatted) => Some(formatted),
Err(error) => {
log::warn!("Error formatting `{}` version:\n{}", module_name, error);
Some(format!("v{}", version))
}
}
}
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,4 +1,5 @@
use super::{Context, Module, RootModuleConfig}; use super::{Context, Module, RootModuleConfig};
use crate::formatter::VersionFormatter;
use crate::configs::cmake::CMakeConfig; use crate::configs::cmake::CMakeConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
@ -30,11 +31,16 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None, _ => None,
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => context "version" => {
.exec_cmd("cmake", &["--version"]) let cmake_version =
.map(|output| format_cmake_version(&output.stdout)) get_cmake_version(&context.exec_cmd("cmake", &["--version"])?.stdout)?;
.flatten() VersionFormatter::format_module_version(
.map(Ok), module.get_name(),
&cmake_version,
config.version_format,
)
.map(Ok)
}
_ => None, _ => None,
}) })
.parse(None) .parse(None)
@ -51,9 +57,15 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module) Some(module)
} }
fn format_cmake_version(cmake_version: &str) -> Option<String> { fn get_cmake_version(cmake_version: &str) -> Option<String> {
let version = cmake_version.split_whitespace().nth(2)?; Some(
Some(format!("v{}", version)) cmake_version
//split into ["cmake" "version" "3.10.2", ...]
.split_whitespace()
// get down to "3.10.2"
.nth(2)?
.to_string(),
)
} }
#[cfg(test)] #[cfg(test)]

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::crystal::CrystalConfig; use crate::configs::crystal::CrystalConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Crystal version /// Creates a module with the current Crystal version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -30,9 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None, _ => None,
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => format_crystal_version( "version" => {
context.exec_cmd("crystal", &["--version"])?.stdout.as_str(), let crystal_version =
) get_crystal_version(&context.exec_cmd("crystal", &["--version"])?.stdout)?;
VersionFormatter::format_module_version(
module.get_name(),
&crystal_version,
config.version_format,
)
}
.map(Ok), .map(Ok),
_ => None, _ => None,
}) })
@ -50,17 +57,15 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module) Some(module)
} }
fn format_crystal_version(crystal_version: &str) -> Option<String> { fn get_crystal_version(crystal_version: &str) -> Option<String> {
let version = crystal_version Some(
// split into ["Crystal", "0.35.1", ...] crystal_version
.split_whitespace() // split into ["Crystal", "0.35.1", ...]
// return "0.35.1" .split_whitespace()
.nth(1)?; // return "0.35.1"
.nth(1)?
let mut formatted_version = String::with_capacity(version.len() + 1); .to_string(),
formatted_version.push('v'); )
formatted_version.push_str(version);
Some(formatted_version)
} }
#[cfg(test)] #[cfg(test)]

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::dart::DartConfig; use crate::configs::dart::DartConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Dart version /// Creates a module with the current Dart version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -31,8 +32,14 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => { "version" => {
let dart_version = context.exec_cmd("dart", &["--version"])?.stderr; let dart_version =
parse_dart_version(&dart_version).map(Ok) get_dart_version(&context.exec_cmd("dart", &["--version"])?.stderr)?;
VersionFormatter::format_module_version(
module.get_name(),
&dart_version,
config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })
@ -50,30 +57,24 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module) Some(module)
} }
fn parse_dart_version(dart_version: &str) -> Option<String> { fn get_dart_version(dart_version: &str) -> Option<String> {
let version = dart_version Some(
// split into ["Dart", "VM", "version:", "2.8.4", "(stable)", ...] dart_version
.split_whitespace() // split into ["Dart", "VM", "version:", "2.8.4", "(stable)", ...]
// return "2.8.4" .split_whitespace()
.nth(3)?; // return "2.8.4"
.nth(3)?
Some(format!("v{}", version)) .to_string(),
)
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::parse_dart_version;
use crate::test::ModuleRenderer; use crate::test::ModuleRenderer;
use ansi_term::Color; use ansi_term::Color;
use std::fs::{self, File}; use std::fs::{self, File};
use std::io; use std::io;
#[test]
fn test_parse_dart_version() {
let input = "Dart VM version: 2.8.4 (stable)";
assert_eq!(parse_dart_version(input), Some("v2.8.4".to_string()));
}
#[test] #[test]
fn folder_without_dart_file() -> io::Result<()> { fn folder_without_dart_file() -> io::Result<()> {
let dir = tempfile::tempdir()?; let dir = tempfile::tempdir()?;

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::deno::DenoConfig; use crate::configs::deno::DenoConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Deno version /// Creates a module with the current Deno version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -27,10 +28,16 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None, _ => None,
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => context "version" => {
.exec_cmd("deno", &["-V"]) let deno_version =
.and_then(|output| parse_deno_version(output.stdout.trim())) get_deno_version(&context.exec_cmd("deno", &["-V"])?.stdout)?;
.map(Ok), VersionFormatter::format_module_version(
module.get_name(),
&deno_version,
config.version_format,
)
.map(Ok)
}
_ => None, _ => None,
}) })
.parse(None) .parse(None)
@ -47,33 +54,24 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module) Some(module)
} }
fn parse_deno_version(deno_version: &str) -> Option<String> { fn get_deno_version(deno_version: &str) -> Option<String> {
let version = deno_version Some(
// split into ["deno", "1.8.3"] deno_version
.split_whitespace() // split into ["deno", "1.8.3"]
// return "1.8.3" .split_whitespace()
.nth(1)?; // return "1.8.3"
.nth(1)?
Some(format!("v{}", version)) .to_string(),
)
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::parse_deno_version;
use crate::test::ModuleRenderer; use crate::test::ModuleRenderer;
use ansi_term::Color; use ansi_term::Color;
use std::fs::File; use std::fs::File;
use std::io; use std::io;
#[test]
fn test_parse_deno_version() {
const OUTPUT: &str = "deno 1.8.3\n";
assert_eq!(
parse_deno_version(OUTPUT.trim()),
Some("v1.8.3".to_string())
)
}
#[test] #[test]
fn folder_without_deno_files() -> io::Result<()> { fn folder_without_deno_files() -> io::Result<()> {
let dir = tempfile::tempdir()?; let dir = tempfile::tempdir()?;

View File

@ -2,7 +2,6 @@ use quick_xml::events::Event;
use quick_xml::Reader; use quick_xml::Reader;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::iter::Iterator; use std::iter::Iterator;
use std::ops::Deref;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str; use std::str;
@ -12,6 +11,7 @@ use crate::formatter::StringFormatter;
use crate::utils; use crate::utils;
type JValue = serde_json::Value; type JValue = serde_json::Value;
use crate::formatter::VersionFormatter;
const GLOBAL_JSON_FILE: &str = "global.json"; const GLOBAL_JSON_FILE: &str = "global.json";
const PROJECT_JSON_FILE: &str = "project.json"; const PROJECT_JSON_FILE: &str = "project.json";
@ -64,7 +64,12 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
} else { } else {
get_version_from_cli(context) get_version_from_cli(context)
}; };
version.map(|v| Ok(v.0)) VersionFormatter::format_module_version(
module.get_name(),
&version?,
config.version_format,
)
.map(Ok)
} }
"tfm" => find_current_tfm(&dotnet_files).map(Ok), "tfm" => find_current_tfm(&dotnet_files).map(Ok),
_ => None, _ => None,
@ -134,7 +139,7 @@ fn estimate_dotnet_version(
files: &[DotNetFile], files: &[DotNetFile],
current_dir: &Path, current_dir: &Path,
repo_root: Option<&Path>, repo_root: Option<&Path>,
) -> Option<Version> { ) -> Option<String> {
let get_file_of_type = |t: FileType| files.iter().find(|f| f.file_type == t); let get_file_of_type = |t: FileType| files.iter().find(|f| f.file_type == t);
// It's important to check for a global.json or a solution file first, // It's important to check for a global.json or a solution file first,
@ -169,7 +174,7 @@ fn estimate_dotnet_version(
/// (Unless there is a git repository, and the parent is above the root of that repository) /// (Unless there is a git repository, and the parent is above the root of that repository)
/// - The root of the git repository /// - The root of the git repository
/// (If there is one) /// (If there is one)
fn try_find_nearby_global_json(current_dir: &Path, repo_root: Option<&Path>) -> Option<Version> { fn try_find_nearby_global_json(current_dir: &Path, repo_root: Option<&Path>) -> Option<String> {
let current_dir_is_repo_root = repo_root.map(|r| r == current_dir).unwrap_or(false); let current_dir_is_repo_root = repo_root.map(|r| r == current_dir).unwrap_or(false);
let parent_dir = if current_dir_is_repo_root { let parent_dir = if current_dir_is_repo_root {
// Don't scan the parent directory if it's above the root of a git repository // Don't scan the parent directory if it's above the root of a git repository
@ -196,7 +201,7 @@ fn try_find_nearby_global_json(current_dir: &Path, repo_root: Option<&Path>) ->
.find_map(|d| check_directory_for_global_json(d)) .find_map(|d| check_directory_for_global_json(d))
} }
fn check_directory_for_global_json(path: &Path) -> Option<Version> { fn check_directory_for_global_json(path: &Path) -> Option<String> {
let global_json_path = path.join(GLOBAL_JSON_FILE); let global_json_path = path.join(GLOBAL_JSON_FILE);
log::debug!( log::debug!(
"Checking if global.json exists at: {}", "Checking if global.json exists at: {}",
@ -209,7 +214,7 @@ fn check_directory_for_global_json(path: &Path) -> Option<Version> {
} }
} }
fn get_pinned_sdk_version_from_file(path: &Path) -> Option<Version> { fn get_pinned_sdk_version_from_file(path: &Path) -> Option<String> {
let json_text = crate::utils::read_file(path).ok()?; let json_text = crate::utils::read_file(path).ok()?;
log::debug!( log::debug!(
"Checking if .NET SDK version is pinned in: {}", "Checking if .NET SDK version is pinned in: {}",
@ -218,7 +223,7 @@ fn get_pinned_sdk_version_from_file(path: &Path) -> Option<Version> {
get_pinned_sdk_version(&json_text) get_pinned_sdk_version(&json_text)
} }
fn get_pinned_sdk_version(json: &str) -> Option<Version> { fn get_pinned_sdk_version(json: &str) -> Option<String> {
let parsed_json: JValue = serde_json::from_str(json).ok()?; let parsed_json: JValue = serde_json::from_str(json).ok()?;
match parsed_json { match parsed_json {
@ -230,9 +235,8 @@ fn get_pinned_sdk_version(json: &str) -> Option<Version> {
match version { match version {
JValue::String(version_string) => { JValue::String(version_string) => {
let mut buffer = String::with_capacity(version_string.len() + 1); let mut buffer = String::with_capacity(version_string.len() + 1);
buffer.push('v');
buffer.push_str(version_string); buffer.push_str(version_string);
Some(Version(buffer)) Some(buffer)
} }
_ => None, _ => None,
} }
@ -282,12 +286,12 @@ fn map_str_to_lower(value: Option<&OsStr>) -> Option<String> {
Some(value?.to_str()?.to_ascii_lowercase()) Some(value?.to_str()?.to_ascii_lowercase())
} }
fn get_version_from_cli(context: &Context) -> Option<Version> { fn get_version_from_cli(context: &Context) -> Option<String> {
let version_output = context.exec_cmd("dotnet", &["--version"])?; let version_output = context.exec_cmd("dotnet", &["--version"])?;
Some(Version(format!("v{}", version_output.stdout.trim()))) Some(format!("v{}", version_output.stdout.trim()))
} }
fn get_latest_sdk_from_cli(context: &Context) -> Option<Version> { fn get_latest_sdk_from_cli(context: &Context) -> Option<String> {
match context.exec_cmd("dotnet", &["--list-sdks"]) { match context.exec_cmd("dotnet", &["--list-sdks"]) {
Some(sdks_output) => { Some(sdks_output) => {
fn parse_failed<T>() -> Option<T> { fn parse_failed<T>() -> Option<T> {
@ -305,9 +309,8 @@ fn get_latest_sdk_from_cli(context: &Context) -> Option<Version> {
if take_until > 1 { if take_until > 1 {
let version = &latest_sdk[..take_until]; let version = &latest_sdk[..take_until];
let mut buffer = String::with_capacity(version.len() + 1); let mut buffer = String::with_capacity(version.len() + 1);
buffer.push('v');
buffer.push_str(version); buffer.push_str(version);
Some(Version(buffer)) Some(buffer)
} else { } else {
parse_failed() parse_failed()
} }
@ -338,15 +341,6 @@ enum FileType {
MsBuildFile, MsBuildFile,
} }
struct Version(String);
impl Deref for Version {
type Target = String;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@ -613,7 +607,7 @@ mod tests {
"#; "#;
let version = get_pinned_sdk_version(json_text).unwrap(); let version = get_pinned_sdk_version(json_text).unwrap();
assert_eq!("v1.2.3", version.0); assert_eq!("1.2.3", version);
} }
#[test] #[test]

View File

@ -3,6 +3,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::elixir::ElixirConfig; use crate::configs::elixir::ElixirConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::ops::Deref; use std::ops::Deref;
@ -39,11 +40,18 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
.deref() .deref()
.as_ref() .as_ref()
.map(|(_, elixir_version)| elixir_version) .map(|(_, elixir_version)| elixir_version)
.map(|elixir_version| {
VersionFormatter::format_module_version(
module.get_name(),
&elixir_version,
config.version_format,
)
})?
.map(Ok), .map(Ok),
"otp_version" => versions "otp_version" => versions
.deref() .deref()
.as_ref() .as_ref()
.map(|(otp_version, _)| otp_version) .map(|(otp_version, _)| otp_version.to_string())
.map(Ok), .map(Ok),
_ => None, _ => None,
}) })
@ -137,7 +145,7 @@ Elixir 1.13.0-dev (compiled with Erlang/OTP 23)
let expected = Some(format!( let expected = Some(format!(
"via {}", "via {}",
Color::Purple.bold().paint("💧 1.10 (OTP 22) ") Color::Purple.bold().paint("💧 v1.10 (OTP 22) ")
)); ));
let output = ModuleRenderer::new("elixir").path(dir.path()).collect(); let output = ModuleRenderer::new("elixir").path(dir.path()).collect();

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::elm::ElmConfig; use crate::configs::elm::ElmConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Elm version /// Creates a module with the current Elm version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -32,8 +33,12 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
.map(|variable| match variable { .map(|variable| match variable {
"version" => { "version" => {
let elm_version = context.exec_cmd("elm", &["--version"])?.stdout; let elm_version = context.exec_cmd("elm", &["--version"])?.stdout;
let module_version = Some(format!("v{}", elm_version.trim()))?; VersionFormatter::format_module_version(
Some(Ok(module_version)) module.get_name(),
&elm_version.trim(),
config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::erlang::ErlangConfig; use crate::configs::erlang::ErlangConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Create a module with the current Erlang version /// Create a module with the current Erlang version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -30,7 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None, _ => None,
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => get_erlang_version(context).map(Ok), "version" => {
let erlang_version = get_erlang_version(context)?;
VersionFormatter::format_module_version(
module.get_name(),
&erlang_version,
config.version_format,
)
.map(Ok)
}
_ => None, _ => None,
}) })
.parse(None) .parse(None)
@ -85,7 +94,7 @@ mod tests {
let dir = tempfile::tempdir()?; let dir = tempfile::tempdir()?;
File::create(dir.path().join("rebar.config"))?.sync_all()?; File::create(dir.path().join("rebar.config"))?.sync_all()?;
let expected = Some(format!("via {}", Color::Red.bold().paint("22.1.3 "))); let expected = Some(format!("via {}", Color::Red.bold().paint("v22.1.3 ")));
let output = ModuleRenderer::new("erlang").path(dir.path()).collect(); let output = ModuleRenderer::new("erlang").path(dir.path()).collect();
assert_eq!(output, expected); assert_eq!(output, expected);

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::go::GoConfig; use crate::configs::go::GoConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Go version /// Creates a module with the current Go version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -30,8 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => { "version" => {
format_go_version(&context.exec_cmd("go", &["version"])?.stdout.as_str()) let golang_version =
.map(Ok) get_go_version(&context.exec_cmd("go", &["version"])?.stdout)?;
VersionFormatter::format_module_version(
module.get_name(),
&golang_version,
config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })
@ -49,7 +57,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module) Some(module)
} }
fn format_go_version(go_stdout: &str) -> Option<String> { fn get_go_version(go_stdout: &str) -> Option<String> {
// go version output looks like this: // go version output looks like this:
// go version go1.13.3 linux/amd64 // go version go1.13.3 linux/amd64
@ -63,7 +71,7 @@ fn format_go_version(go_stdout: &str) -> Option<String> {
// return "1.12.4" // return "1.12.4"
.next()?; .next()?;
Some(format!("v{}", version)) Some(version.to_string())
} }
#[cfg(test)] #[cfg(test)]
@ -181,6 +189,6 @@ mod tests {
#[test] #[test]
fn test_format_go_version() { fn test_format_go_version() {
let input = "go version go1.12 darwin/amd64"; let input = "go version go1.12 darwin/amd64";
assert_eq!(format_go_version(input), Some("v1.12".to_string())); assert_eq!(get_go_version(input), Some("1.12".to_string()));
} }
} }

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::helm::HelmConfig; use crate::configs::helm::HelmConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Helm version /// Creates a module with the current Helm version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -30,13 +31,19 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None, _ => None,
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => format_helm_version( "version" => {
&context let helm_version = get_helm_version(
.exec_cmd("helm", &["version", "--short", "--client"])? &context
.stdout .exec_cmd("helm", &["version", "--short", "--client"])?
.as_str(), .stdout,
) )?;
.map(Ok), VersionFormatter::format_module_version(
module.get_name(),
&helm_version,
config.version_format,
)
.map(Ok)
}
_ => None, _ => None,
}) })
.parse(None) .parse(None)
@ -53,24 +60,23 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module) Some(module)
} }
fn format_helm_version(helm_stdout: &str) -> Option<String> { fn get_helm_version(helm_stdout: &str) -> Option<String> {
// `helm version --short --client` output looks like this: // `helm version --short --client` output looks like this:
// v3.1.1+gafe7058 // v3.1.1+gafe7058
// `helm version --short --client` output looks like this for Helm 2: // `helm version --short --client` output looks like this for Helm 2:
// Client: v2.16.9+g8ad7037 // Client: v2.16.9+g8ad7037
let version = helm_stdout
Some( // split into ["v3.1.1","gafe7058"] or ["Client: v3.1.1","gafe7058"]
helm_stdout .splitn(2, '+')
// split into ["v3.1.1","gafe7058"] or ["Client: v3.1.1","gafe7058"] // return "v3.1.1" or "Client: v3.1.1"
.splitn(2, '+') .next()?
// return "v3.1.1" or "Client: v3.1.1" // return "v3.1.1" or " v3.1.1"
.next()? .trim_start_matches("Client: ")
// return "v3.1.1" or " v3.1.1" // return "v3.1.1"
.trim_start_matches("Client: ") .trim_start_matches('v')
// return "v3.1.1" .trim()
.trim() .to_string();
.to_owned(), Some(version)
)
} }
#[cfg(test)] #[cfg(test)]
@ -117,10 +123,10 @@ mod tests {
} }
#[test] #[test]
fn test_format_helm_version() { fn test_get_helm_version() {
let helm_2 = "Client: v2.16.9+g8ad7037"; let helm_2 = "Client: v2.16.9+g8ad7037";
let helm_3 = "v3.1.1+ggit afe7058"; let helm_3 = "v3.1.1+ggit afe7058";
assert_eq!(format_helm_version(helm_2), Some("v2.16.9".to_string())); assert_eq!(get_helm_version(helm_2), Some("2.16.9".to_string()));
assert_eq!(format_helm_version(helm_3), Some("v3.1.1".to_string())); assert_eq!(get_helm_version(helm_3), Some("3.1.1".to_string()));
} }
} }

View File

@ -82,7 +82,7 @@ fn format_java_version(java_version: &str, version_format: &str) -> Option<Strin
match VersionFormatter::format_version(version, version_format) { match VersionFormatter::format_version(version, version_format) {
Ok(formatted) => Some(formatted), Ok(formatted) => Some(formatted),
Err(error) => { Err(error) => {
log::warn!("Error formating `java` version:\n{}", error); log::warn!("Error formatting `java` version:\n{}", error);
Some(format!("v{}", version)) Some(format!("v{}", version))
} }
} }

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::julia::JuliaConfig; use crate::configs::julia::JuliaConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Julia version /// Creates a module with the current Julia version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -30,10 +31,16 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None, _ => None,
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => format_julia_version( "version" => {
&context.exec_cmd("julia", &["--version"])?.stdout.as_str(), let julia_version =
) get_julia_version(&context.exec_cmd("julia", &["--version"])?.stdout)?;
.map(Ok), VersionFormatter::format_module_version(
module.get_name(),
&julia_version,
config.version_format,
)
.map(Ok)
}
_ => None, _ => None,
}) })
.parse(None) .parse(None)
@ -50,7 +57,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module) Some(module)
} }
fn format_julia_version(julia_stdout: &str) -> Option<String> { fn get_julia_version(julia_stdout: &str) -> Option<String> {
// julia version output looks like this: // julia version output looks like this:
// julia version 1.4.0 // julia version 1.4.0
@ -62,7 +69,7 @@ fn format_julia_version(julia_stdout: &str) -> Option<String> {
.split_whitespace() .split_whitespace()
.next()?; .next()?;
Some(format!("v{}", version)) Some(version.to_string())
} }
#[cfg(test)] #[cfg(test)]
@ -121,8 +128,8 @@ mod tests {
} }
#[test] #[test]
fn test_format_julia_version() { fn test_get_julia_version() {
let input = "julia version 1.4.0"; let input = "julia version 1.4.0";
assert_eq!(format_julia_version(input), Some("v1.4.0".to_string())); assert_eq!(get_julia_version(input), Some("1.4.0".to_string()));
} }
} }

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::kotlin::KotlinConfig; use crate::configs::kotlin::KotlinConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
use regex::Regex; use regex::Regex;
const KOTLIN_VERSION_PATTERN: &str = "(?P<version>[\\d\\.]+[\\d\\.]+[\\d\\.]+)"; const KOTLIN_VERSION_PATTERN: &str = "(?P<version>[\\d\\.]+[\\d\\.]+[\\d\\.]+)";
@ -34,11 +35,13 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => { "version" => {
let kotlin_version = format_kotlin_version(&get_kotlin_version( let kotlin_version = get_kotlin_version(context, &config.kotlin_binary)?;
context, VersionFormatter::format_module_version(
&config.kotlin_binary, module.get_name(),
)?)?; &kotlin_version,
Some(Ok(kotlin_version)) config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })
@ -59,26 +62,26 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
fn get_kotlin_version(context: &Context, kotlin_binary: &str) -> Option<String> { fn get_kotlin_version(context: &Context, kotlin_binary: &str) -> Option<String> {
match context.exec_cmd(kotlin_binary, &["-version"]) { match context.exec_cmd(kotlin_binary, &["-version"]) {
Some(output) => { Some(output) => {
if output.stdout.is_empty() { let kotlin_output = if output.stdout.is_empty() {
Some(output.stderr) output.stderr
} else { } else {
Some(output.stdout) output.stdout
} };
parse_kotlin_version(&kotlin_output)
} }
None => None, None => None,
} }
} }
fn format_kotlin_version(kotlin_stdout: &str) -> Option<String> { fn parse_kotlin_version(kotlin_stdout: &str) -> Option<String> {
// kotlin -version output looks like this: // kotlin -version output looks like this:
// Kotlin version 1.4.21-release-411 (JRE 14.0.1+7) // Kotlin version 1.4.21-release-411 (JRE 14.0.1+7)
// kotlinc -version output looks like this: // kotlinc -version output looks like this:
// info: kotlinc-jvm 1.4.21 (JRE 14.0.1+7) // info: kotlinc-jvm 1.4.21 (JRE 14.0.1+7)
let re = Regex::new(KOTLIN_VERSION_PATTERN).ok()?; let re = Regex::new(KOTLIN_VERSION_PATTERN).ok()?;
let captures = re.captures(kotlin_stdout)?; let captures = re.captures(kotlin_stdout)?;
let version = &captures["version"]; let version = &captures["version"];
Some(format!("v{}", version)) Some(version.to_string())
} }
#[cfg(test)] #[cfg(test)]
@ -159,20 +162,20 @@ mod tests {
} }
#[test] #[test]
fn test_format_kotlin_version_from_runtime() { fn test_parse_kotlin_version_from_runtime() {
let kotlin_input = "Kotlin version 1.4.21-release-411 (JRE 14.0.1+7)"; let kotlin_input = "Kotlin version 1.4.21-release-411 (JRE 14.0.1+7)";
assert_eq!( assert_eq!(
format_kotlin_version(kotlin_input), parse_kotlin_version(kotlin_input),
Some("v1.4.21".to_string()) Some("1.4.21".to_string())
); );
} }
#[test] #[test]
fn test_format_kotlin_version_from_compiler() { fn test_parse_kotlin_version_from_compiler() {
let kotlin_input = "info: kotlinc-jvm 1.4.21 (JRE 14.0.1+7)"; let kotlin_input = "info: kotlinc-jvm 1.4.21 (JRE 14.0.1+7)";
assert_eq!( assert_eq!(
format_kotlin_version(kotlin_input), parse_kotlin_version(kotlin_input),
Some("v1.4.21".to_string()) Some("1.4.21".to_string())
); );
} }
} }

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::lua::LuaConfig; use crate::configs::lua::LuaConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Lua version /// Creates a module with the current Lua version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -30,7 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None, _ => None,
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => get_lua_version(context, &config.lua_binary).map(Ok), "version" => {
let lua_version = get_lua_version(context, &config.lua_binary)?;
VersionFormatter::format_module_version(
module.get_name(),
&lua_version,
config.version_format,
)
.map(Ok)
}
_ => None, _ => None,
}) })
.parse(None) .parse(None)
@ -72,7 +81,7 @@ fn parse_lua_version(lua_version: &str) -> Option<String> {
// LuaJIT: take "2.0.5" // LuaJIT: take "2.0.5"
.nth(1)?; .nth(1)?;
Some(format!("v{}", version)) Some(version.to_string())
} }
#[cfg(test)] #[cfg(test)]
@ -148,13 +157,13 @@ mod tests {
#[test] #[test]
fn test_parse_lua_version() { fn test_parse_lua_version() {
let lua_input = "Lua 5.4.0 Copyright (C) 1994-2020 Lua.org, PUC-Rio"; let lua_input = "Lua 5.4.0 Copyright (C) 1994-2020 Lua.org, PUC-Rio";
assert_eq!(parse_lua_version(lua_input), Some("v5.4.0".to_string())); assert_eq!(parse_lua_version(lua_input), Some("5.4.0".to_string()));
let luajit_input = let luajit_input =
"LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/"; "LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/";
assert_eq!( assert_eq!(
parse_lua_version(luajit_input), parse_lua_version(luajit_input),
Some("v2.1.0-beta3".to_string()) Some("2.1.0-beta3".to_string())
); );
} }
} }

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::nim::NimConfig; use crate::configs::nim::NimConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Nim version /// Creates a module with the current Nim version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -33,7 +34,12 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
.exec_cmd("nim", &["--version"]) .exec_cmd("nim", &["--version"])
.map(|command_output| command_output.stdout) .map(|command_output| command_output.stdout)
.and_then(|nim_version_output| { .and_then(|nim_version_output| {
Some(format!("v{}", parse_nim_version(&nim_version_output)?)) let nim_version = parse_nim_version(&nim_version_output)?;
VersionFormatter::format_module_version(
module.get_name(),
nim_version,
config.version_format,
)
}) })
.map(Ok), .map(Ok),
_ => None, _ => None,

View File

@ -112,7 +112,7 @@ fn format_node_version(node_version: &str, version_format: &str) -> String {
match VersionFormatter::format_version(version, version_format) { match VersionFormatter::format_version(version, version_format) {
Ok(formatted) => formatted, Ok(formatted) => formatted,
Err(error) => { Err(error) => {
log::warn!("Error formating `node` version:\n{}", error); log::warn!("Error formatting `node` version:\n{}", error);
format!("v{}", version) format!("v{}", version)
} }
} }

View File

@ -5,6 +5,7 @@ use std::path::Path;
use crate::configs::ocaml::OCamlConfig; use crate::configs::ocaml::OCamlConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
enum SwitchType { enum SwitchType {
@ -63,7 +64,12 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
} else { } else {
context.exec_cmd("ocaml", &["-vnum"])?.stdout context.exec_cmd("ocaml", &["-vnum"])?.stdout
}; };
Some(Ok(format!("v{}", &ocaml_version.trim()))) VersionFormatter::format_module_version(
module.get_name(),
&ocaml_version.trim(),
config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::perl::PerlConfig; use crate::configs::perl::PerlConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current perl version /// Creates a module with the current perl version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -33,7 +34,12 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let perl_version = context let perl_version = context
.exec_cmd("perl", &["-e", "printf q#%vd#,$^V;"])? .exec_cmd("perl", &["-e", "printf q#%vd#,$^V;"])?
.stdout; .stdout;
Some(Ok(format!("v{}", perl_version))) VersionFormatter::format_module_version(
module.get_name(),
&perl_version,
config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::php::PhpConfig; use crate::configs::php::PhpConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current PHP version /// Creates a module with the current PHP version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -30,14 +31,14 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => { "version" => {
let php_cmd_output = context.exec_cmd( let php_version = context.exec_cmd(
"php", "php",
&[ &[
"-nr", "-nr",
"echo PHP_MAJOR_VERSION.\".\".PHP_MINOR_VERSION.\".\".PHP_RELEASE_VERSION;", "echo PHP_MAJOR_VERSION.\".\".PHP_MINOR_VERSION.\".\".PHP_RELEASE_VERSION;",
], ],
)?; )?.stdout;
Some(Ok(format_php_version(&php_cmd_output.stdout))) VersionFormatter::format_module_version(module.get_name(), &php_version, config.version_format).map(Ok)
} }
_ => None, _ => None,
}) })
@ -55,24 +56,13 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module) Some(module)
} }
fn format_php_version(php_version: &str) -> String {
format!("v{}", php_version)
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::test::ModuleRenderer; use crate::test::ModuleRenderer;
use ansi_term::Color; use ansi_term::Color;
use std::fs::File; use std::fs::File;
use std::io; use std::io;
#[test]
fn test_format_php_version() {
let input = "7.3.8";
assert_eq!(format_php_version(input), "v7.3.8".to_string());
}
#[test] #[test]
fn folder_without_php_files() -> io::Result<()> { fn folder_without_php_files() -> io::Result<()> {
let dir = tempfile::tempdir()?; let dir = tempfile::tempdir()?;

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::purescript::PureScriptConfig; use crate::configs::purescript::PureScriptConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current PureScript version /// Creates a module with the current PureScript version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -31,7 +32,12 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
.map(|variable| match variable { .map(|variable| match variable {
"version" => { "version" => {
let purs_version = context.exec_cmd("purs", &["--version"])?.stdout; let purs_version = context.exec_cmd("purs", &["--version"])?.stdout;
Some(Ok(format!("v{}", purs_version.trim()))) VersionFormatter::format_module_version(
module.get_name(),
&purs_version.trim(),
config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })

View File

@ -94,7 +94,7 @@ fn format_python_version(python_version: &str, version_format: &str) -> Option<S
match VersionFormatter::format_version(version, version_format) { match VersionFormatter::format_version(version, version_format) {
Ok(formatted) => Some(formatted), Ok(formatted) => Some(formatted),
Err(error) => { Err(error) => {
log::warn!("Error formating `python` version:\n{}", error); log::warn!("Error formatting `python` version:\n{}", error);
Some(format!("v{}", version)) Some(format!("v{}", version))
} }
} }

View File

@ -69,7 +69,7 @@ fn format_ruby_version(ruby_version: &str, version_format: &str) -> Option<Strin
match VersionFormatter::format_version(version, version_format) { match VersionFormatter::format_version(version, version_format) {
Ok(formatted) => Some(formatted), Ok(formatted) => Some(formatted),
Err(error) => { Err(error) => {
log::warn!("Error formating `ruby` version:\n{}", error); log::warn!("Error formatting `ruby` version:\n{}", error);
Some(format!("v{}", version)) Some(format!("v{}", version))
} }
} }

View File

@ -213,7 +213,7 @@ fn format_rustc_version(rustc_version: &str, version_format: &str) -> Option<Str
match VersionFormatter::format_version(version, version_format) { match VersionFormatter::format_version(version, version_format) {
Ok(formatted) => Some(formatted), Ok(formatted) => Some(formatted),
Err(error) => { Err(error) => {
log::warn!("Error formating `rust` version:\n{}", error); log::warn!("Error formatting `rust` version:\n{}", error);
Some(format!("v{}", version)) Some(format!("v{}", version))
} }
} }

View File

@ -2,6 +2,7 @@ use crate::configs::scala::ScalaConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use super::{Context, Module, RootModuleConfig}; use super::{Context, Module, RootModuleConfig};
use crate::formatter::VersionFormatter;
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let mut module = context.new_module("scala"); let mut module = context.new_module("scala");
@ -31,7 +32,12 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
.map(|variable| match variable { .map(|variable| match variable {
"version" => { "version" => {
let scala_version = get_scala_version(context)?; let scala_version = get_scala_version(context)?;
Some(Ok(scala_version)) VersionFormatter::format_module_version(
module.get_name(),
&scala_version,
config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })
@ -67,7 +73,7 @@ fn parse_scala_version(scala_version: &str) -> Option<String> {
// take "2.13.5" // take "2.13.5"
.nth(3)?; .nth(3)?;
Some(format!("v{}", &version)) Some(version.to_string())
} }
#[cfg(test)] #[cfg(test)]
@ -82,7 +88,7 @@ mod tests {
fn test_parse_scala_version() { fn test_parse_scala_version() {
let scala_2_13 = let scala_2_13 =
"Scala compiler version 2.13.5 -- Copyright 2002-2020, LAMP/EPFL and Lightbend, Inc."; "Scala compiler version 2.13.5 -- Copyright 2002-2020, LAMP/EPFL and Lightbend, Inc.";
assert_eq!(parse_scala_version(scala_2_13), Some("v2.13.5".to_string())); assert_eq!(parse_scala_version(scala_2_13), Some("2.13.5".to_string()));
} }
#[test] #[test]
@ -90,7 +96,7 @@ mod tests {
let dotty_version = "Scala compiler version 3.0.0-RC1 -- Copyright 2002-2021, LAMP/EPFL"; let dotty_version = "Scala compiler version 3.0.0-RC1 -- Copyright 2002-2021, LAMP/EPFL";
assert_eq!( assert_eq!(
parse_scala_version(dotty_version), parse_scala_version(dotty_version),
Some("v3.0.0-RC1".to_string()) Some("3.0.0-RC1".to_string())
); );
} }

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::swift::SwiftConfig; use crate::configs::swift::SwiftConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Swift version /// Creates a module with the current Swift version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -31,8 +32,14 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => { "version" => {
let swift_version = context.exec_cmd("swift", &["--version"])?.stdout; let swift_version =
parse_swift_version(&swift_version).map(Ok) parse_swift_version(&context.exec_cmd("swift", &["--version"])?.stdout)?;
VersionFormatter::format_module_version(
module.get_name(),
&swift_version,
config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })
@ -58,7 +65,7 @@ fn parse_swift_version(swift_version: &str) -> Option<String> {
// return "5.2.2" or "5.3-dev" // return "5.2.2" or "5.3-dev"
let version = splited.next()?; let version = splited.next()?;
Some(format!("v{}", version)) Some(version.to_string())
} }
#[cfg(test)] #[cfg(test)]
@ -72,13 +79,13 @@ mod tests {
#[test] #[test]
fn test_parse_swift_version() { fn test_parse_swift_version() {
let input = "Apple Swift version 5.2.2"; let input = "Apple Swift version 5.2.2";
assert_eq!(parse_swift_version(input), Some(String::from("v5.2.2"))); assert_eq!(parse_swift_version(input), Some(String::from("5.2.2")));
} }
#[test] #[test]
fn test_parse_swift_version_without_org_name() { fn test_parse_swift_version_without_org_name() {
let input = "Swift version 5.3-dev (LLVM ..., Swift ...)"; let input = "Swift version 5.3-dev (LLVM ..., Swift ...)";
assert_eq!(parse_swift_version(input), Some(String::from("v5.3-dev"))); assert_eq!(parse_swift_version(input), Some(String::from("5.3-dev")));
} }
#[test] #[test]

View File

@ -4,6 +4,7 @@ use crate::configs::terraform::TerraformConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::utils; use crate::utils;
use crate::formatter::VersionFormatter;
use std::io; use std::io;
use std::path::PathBuf; use std::path::PathBuf;
@ -34,9 +35,16 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None, _ => None,
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => format_terraform_version( "version" => {
&context.exec_cmd("terraform", &["version"])?.stdout.as_str(), let terraform_version = get_terraform_version(
) &context.exec_cmd("terraform", &["version"])?.stdout.as_str(),
)?;
VersionFormatter::format_module_version(
module.get_name(),
&terraform_version,
config.version_format,
)
}
.map(Ok), .map(Ok),
"workspace" => get_terraform_workspace(context).map(Ok), "workspace" => get_terraform_workspace(context).map(Ok),
_ => None, _ => None,
@ -75,7 +83,7 @@ fn get_terraform_workspace(context: &Context) -> Option<String> {
} }
} }
fn format_terraform_version(version: &str) -> Option<String> { fn get_terraform_version(version: &str) -> Option<String> {
// `terraform version` output looks like this // `terraform version` output looks like this
// Terraform v0.12.14 // Terraform v0.12.14
// With potential extra output if it detects you are not running the latest version // With potential extra output if it detects you are not running the latest version
@ -85,6 +93,7 @@ fn format_terraform_version(version: &str) -> Option<String> {
.next()? .next()?
.trim_start_matches("Terraform ") .trim_start_matches("Terraform ")
.trim() .trim()
.trim_start_matches('v')
.to_owned() .to_owned()
+ " ", + " ",
) )
@ -99,44 +108,38 @@ mod tests {
use std::io::{self, Write}; use std::io::{self, Write};
#[test] #[test]
fn test_format_terraform_version_release() { fn test_get_terraform_version_release() {
let input = "Terraform v0.12.14"; let input = "Terraform v0.12.14";
assert_eq!( assert_eq!(get_terraform_version(input), Some("0.12.14 ".to_string()));
format_terraform_version(input),
Some("v0.12.14 ".to_string())
);
} }
#[test] #[test]
fn test_format_terraform_version_prerelease() { fn test_get_terraform_version_prerelease() {
let input = "Terraform v0.12.14-rc1"; let input = "Terraform v0.12.14-rc1";
assert_eq!( assert_eq!(
format_terraform_version(input), get_terraform_version(input),
Some("v0.12.14-rc1 ".to_string()) Some("0.12.14-rc1 ".to_string())
); );
} }
#[test] #[test]
fn test_format_terraform_version_development() { fn test_get_terraform_version_development() {
let input = "Terraform v0.12.14-dev (cca89f74)"; let input = "Terraform v0.12.14-dev (cca89f74)";
assert_eq!( assert_eq!(
format_terraform_version(input), get_terraform_version(input),
Some("v0.12.14-dev (cca89f74) ".to_string()) Some("0.12.14-dev (cca89f74) ".to_string())
); );
} }
#[test] #[test]
fn test_format_terraform_version_multiline() { fn test_get_terraform_version_multiline() {
let input = "Terraform v0.12.13 let input = "Terraform v0.12.13
Your version of Terraform is out of date! The latest version Your version of Terraform is out of date! The latest version
is 0.12.14. You can update by downloading from www.terraform.io/downloads.html is 0.12.14. You can update by downloading from www.terraform.io/downloads.html
"; ";
assert_eq!( assert_eq!(get_terraform_version(input), Some("0.12.13 ".to_string()));
format_terraform_version(input),
Some("v0.12.13 ".to_string())
);
} }
#[test] #[test]

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::vagrant::VagrantConfig; use crate::configs::vagrant::VagrantConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Vagrant version /// Creates a module with the current Vagrant version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -30,9 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None, _ => None,
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => format_vagrant_version( "version" => {
&context.exec_cmd("vagrant", &["--version"])?.stdout.as_str(), let vagrant_version =
) get_vagrant_version(&context.exec_cmd("vagrant", &["--version"])?.stdout)?;
VersionFormatter::format_module_version(
module.get_name(),
&vagrant_version,
config.version_format,
)
}
.map(Ok), .map(Ok),
_ => None, _ => None,
}) })
@ -50,7 +57,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module) Some(module)
} }
fn format_vagrant_version(vagrant_stdout: &str) -> Option<String> { fn get_vagrant_version(vagrant_stdout: &str) -> Option<String> {
// `vagrant --version` output looks like this: // `vagrant --version` output looks like this:
// Vagrant 2.2.10 // Vagrant 2.2.10
let version = vagrant_stdout let version = vagrant_stdout
@ -59,10 +66,7 @@ fn format_vagrant_version(vagrant_stdout: &str) -> Option<String> {
// return "2.2.10" // return "2.2.10"
.nth(1)?; .nth(1)?;
let mut formatted_version = String::with_capacity(version.len() + 1); Some(version.to_string())
formatted_version.push('v');
formatted_version.push_str(version);
Some(formatted_version)
} }
#[cfg(test)] #[cfg(test)]
@ -97,8 +101,8 @@ mod tests {
} }
#[test] #[test]
fn test_format_vagrant_version() { fn test_get_vagrant_version() {
let vagrant = "Vagrant 2.2.10\n"; let vagrant = "Vagrant 2.2.10\n";
assert_eq!(format_vagrant_version(vagrant), Some("v2.2.10".to_string())); assert_eq!(get_vagrant_version(vagrant), Some("2.2.10".to_string()));
} }
} }

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::zig::ZigConfig; use crate::configs::zig::ZigConfig;
use crate::formatter::StringFormatter; use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Zig version /// Creates a module with the current Zig version
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
@ -31,9 +32,13 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
}) })
.map(|variable| match variable { .map(|variable| match variable {
"version" => { "version" => {
let zig_version_output = context.exec_cmd("zig", &["version"])?.stdout; let zig_version = context.exec_cmd("zig", &["version"])?.stdout;
let zig_version = format!("v{}", zig_version_output.trim()); VersionFormatter::format_module_version(
Some(Ok(zig_version)) module.get_name(),
&zig_version.trim(),
config.version_format,
)
.map(Ok)
} }
_ => None, _ => None,
}) })