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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,6 +60,20 @@ impl<'a> VersionFormatter<'a> {
.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)]

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,6 @@ use quick_xml::events::Event;
use quick_xml::Reader;
use std::ffi::OsStr;
use std::iter::Iterator;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::str;
@ -12,6 +11,7 @@ use crate::formatter::StringFormatter;
use crate::utils;
type JValue = serde_json::Value;
use crate::formatter::VersionFormatter;
const GLOBAL_JSON_FILE: &str = "global.json";
const PROJECT_JSON_FILE: &str = "project.json";
@ -64,7 +64,12 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
} else {
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),
_ => None,
@ -134,7 +139,7 @@ fn estimate_dotnet_version(
files: &[DotNetFile],
current_dir: &Path,
repo_root: Option<&Path>,
) -> Option<Version> {
) -> Option<String> {
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,
@ -169,7 +174,7 @@ fn estimate_dotnet_version(
/// (Unless there is a git repository, and the parent is above the root of that repository)
/// - The root of the git repository
/// (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 parent_dir = if current_dir_is_repo_root {
// 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))
}
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);
log::debug!(
"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()?;
log::debug!(
"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)
}
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()?;
match parsed_json {
@ -230,9 +235,8 @@ fn get_pinned_sdk_version(json: &str) -> Option<Version> {
match version {
JValue::String(version_string) => {
let mut buffer = String::with_capacity(version_string.len() + 1);
buffer.push('v');
buffer.push_str(version_string);
Some(Version(buffer))
Some(buffer)
}
_ => None,
}
@ -282,12 +286,12 @@ fn map_str_to_lower(value: Option<&OsStr>) -> Option<String> {
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"])?;
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"]) {
Some(sdks_output) => {
fn parse_failed<T>() -> Option<T> {
@ -305,9 +309,8 @@ fn get_latest_sdk_from_cli(context: &Context) -> Option<Version> {
if take_until > 1 {
let version = &latest_sdk[..take_until];
let mut buffer = String::with_capacity(version.len() + 1);
buffer.push('v');
buffer.push_str(version);
Some(Version(buffer))
Some(buffer)
} else {
parse_failed()
}
@ -338,15 +341,6 @@ enum FileType {
MsBuildFile,
}
struct Version(String);
impl Deref for Version {
type Target = String;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[cfg(test)]
mod tests {
use super::*;
@ -613,7 +607,7 @@ mod tests {
"#;
let version = get_pinned_sdk_version(json_text).unwrap();
assert_eq!("v1.2.3", version.0);
assert_eq!("1.2.3", version);
}
#[test]

View File

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

View File

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

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::erlang::ErlangConfig;
use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Create a module with the current Erlang version
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,
})
.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,
})
.parse(None)
@ -85,7 +94,7 @@ mod tests {
let dir = tempfile::tempdir()?;
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();
assert_eq!(output, expected);

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::go::GoConfig;
use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Go version
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 {
"version" => {
format_go_version(&context.exec_cmd("go", &["version"])?.stdout.as_str())
.map(Ok)
let golang_version =
get_go_version(&context.exec_cmd("go", &["version"])?.stdout)?;
VersionFormatter::format_module_version(
module.get_name(),
&golang_version,
config.version_format,
)
.map(Ok)
}
_ => None,
})
@ -49,7 +57,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
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 go1.13.3 linux/amd64
@ -63,7 +71,7 @@ fn format_go_version(go_stdout: &str) -> Option<String> {
// return "1.12.4"
.next()?;
Some(format!("v{}", version))
Some(version.to_string())
}
#[cfg(test)]
@ -181,6 +189,6 @@ mod tests {
#[test]
fn test_format_go_version() {
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::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Helm version
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,
})
.map(|variable| match variable {
"version" => format_helm_version(
&context
.exec_cmd("helm", &["version", "--short", "--client"])?
.stdout
.as_str(),
)
.map(Ok),
"version" => {
let helm_version = get_helm_version(
&context
.exec_cmd("helm", &["version", "--short", "--client"])?
.stdout,
)?;
VersionFormatter::format_module_version(
module.get_name(),
&helm_version,
config.version_format,
)
.map(Ok)
}
_ => None,
})
.parse(None)
@ -53,24 +60,23 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
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:
// v3.1.1+gafe7058
// `helm version --short --client` output looks like this for Helm 2:
// Client: v2.16.9+g8ad7037
Some(
helm_stdout
// split into ["v3.1.1","gafe7058"] or ["Client: v3.1.1","gafe7058"]
.splitn(2, '+')
// return "v3.1.1" or "Client: v3.1.1"
.next()?
// return "v3.1.1" or " v3.1.1"
.trim_start_matches("Client: ")
// return "v3.1.1"
.trim()
.to_owned(),
)
let version = helm_stdout
// split into ["v3.1.1","gafe7058"] or ["Client: v3.1.1","gafe7058"]
.splitn(2, '+')
// return "v3.1.1" or "Client: v3.1.1"
.next()?
// return "v3.1.1" or " v3.1.1"
.trim_start_matches("Client: ")
// return "v3.1.1"
.trim_start_matches('v')
.trim()
.to_string();
Some(version)
}
#[cfg(test)]
@ -117,10 +123,10 @@ mod tests {
}
#[test]
fn test_format_helm_version() {
fn test_get_helm_version() {
let helm_2 = "Client: v2.16.9+g8ad7037";
let helm_3 = "v3.1.1+ggit afe7058";
assert_eq!(format_helm_version(helm_2), Some("v2.16.9".to_string()));
assert_eq!(format_helm_version(helm_3), Some("v3.1.1".to_string()));
assert_eq!(get_helm_version(helm_2), Some("2.16.9".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) {
Ok(formatted) => Some(formatted),
Err(error) => {
log::warn!("Error formating `java` version:\n{}", error);
log::warn!("Error formatting `java` version:\n{}", error);
Some(format!("v{}", version))
}
}

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::julia::JuliaConfig;
use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Julia version
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,
})
.map(|variable| match variable {
"version" => format_julia_version(
&context.exec_cmd("julia", &["--version"])?.stdout.as_str(),
)
.map(Ok),
"version" => {
let julia_version =
get_julia_version(&context.exec_cmd("julia", &["--version"])?.stdout)?;
VersionFormatter::format_module_version(
module.get_name(),
&julia_version,
config.version_format,
)
.map(Ok)
}
_ => None,
})
.parse(None)
@ -50,7 +57,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
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 1.4.0
@ -62,7 +69,7 @@ fn format_julia_version(julia_stdout: &str) -> Option<String> {
.split_whitespace()
.next()?;
Some(format!("v{}", version))
Some(version.to_string())
}
#[cfg(test)]
@ -121,8 +128,8 @@ mod tests {
}
#[test]
fn test_format_julia_version() {
fn test_get_julia_version() {
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::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
use regex::Regex;
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 {
"version" => {
let kotlin_version = format_kotlin_version(&get_kotlin_version(
context,
&config.kotlin_binary,
)?)?;
Some(Ok(kotlin_version))
let kotlin_version = get_kotlin_version(context, &config.kotlin_binary)?;
VersionFormatter::format_module_version(
module.get_name(),
&kotlin_version,
config.version_format,
)
.map(Ok)
}
_ => 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> {
match context.exec_cmd(kotlin_binary, &["-version"]) {
Some(output) => {
if output.stdout.is_empty() {
Some(output.stderr)
let kotlin_output = if output.stdout.is_empty() {
output.stderr
} else {
Some(output.stdout)
}
output.stdout
};
parse_kotlin_version(&kotlin_output)
}
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 1.4.21-release-411 (JRE 14.0.1+7)
// kotlinc -version output looks like this:
// info: kotlinc-jvm 1.4.21 (JRE 14.0.1+7)
let re = Regex::new(KOTLIN_VERSION_PATTERN).ok()?;
let captures = re.captures(kotlin_stdout)?;
let version = &captures["version"];
Some(format!("v{}", version))
Some(version.to_string())
}
#[cfg(test)]
@ -159,20 +162,20 @@ mod tests {
}
#[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)";
assert_eq!(
format_kotlin_version(kotlin_input),
Some("v1.4.21".to_string())
parse_kotlin_version(kotlin_input),
Some("1.4.21".to_string())
);
}
#[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)";
assert_eq!(
format_kotlin_version(kotlin_input),
Some("v1.4.21".to_string())
parse_kotlin_version(kotlin_input),
Some("1.4.21".to_string())
);
}
}

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::lua::LuaConfig;
use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Lua version
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,
})
.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,
})
.parse(None)
@ -72,7 +81,7 @@ fn parse_lua_version(lua_version: &str) -> Option<String> {
// LuaJIT: take "2.0.5"
.nth(1)?;
Some(format!("v{}", version))
Some(version.to_string())
}
#[cfg(test)]
@ -148,13 +157,13 @@ mod tests {
#[test]
fn test_parse_lua_version() {
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 =
"LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/";
assert_eq!(
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::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Nim version
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"])
.map(|command_output| command_output.stdout)
.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),
_ => 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) {
Ok(formatted) => formatted,
Err(error) => {
log::warn!("Error formating `node` version:\n{}", error);
log::warn!("Error formatting `node` version:\n{}", error);
format!("v{}", version)
}
}

View File

@ -5,6 +5,7 @@ use std::path::Path;
use crate::configs::ocaml::OCamlConfig;
use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
#[derive(Debug, PartialEq)]
enum SwitchType {
@ -63,7 +64,12 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
} else {
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,
})

View File

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

View File

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

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::purescript::PureScriptConfig;
use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current PureScript version
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 {
"version" => {
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,
})

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) {
Ok(formatted) => Some(formatted),
Err(error) => {
log::warn!("Error formating `python` version:\n{}", error);
log::warn!("Error formatting `python` version:\n{}", error);
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) {
Ok(formatted) => Some(formatted),
Err(error) => {
log::warn!("Error formating `ruby` version:\n{}", error);
log::warn!("Error formatting `ruby` version:\n{}", error);
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) {
Ok(formatted) => Some(formatted),
Err(error) => {
log::warn!("Error formating `rust` version:\n{}", error);
log::warn!("Error formatting `rust` version:\n{}", error);
Some(format!("v{}", version))
}
}

View File

@ -2,6 +2,7 @@ use crate::configs::scala::ScalaConfig;
use crate::formatter::StringFormatter;
use super::{Context, Module, RootModuleConfig};
use crate::formatter::VersionFormatter;
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
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 {
"version" => {
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,
})
@ -67,7 +73,7 @@ fn parse_scala_version(scala_version: &str) -> Option<String> {
// take "2.13.5"
.nth(3)?;
Some(format!("v{}", &version))
Some(version.to_string())
}
#[cfg(test)]
@ -82,7 +88,7 @@ mod tests {
fn test_parse_scala_version() {
let scala_2_13 =
"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]
@ -90,7 +96,7 @@ mod tests {
let dotty_version = "Scala compiler version 3.0.0-RC1 -- Copyright 2002-2021, LAMP/EPFL";
assert_eq!(
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::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Swift version
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 {
"version" => {
let swift_version = context.exec_cmd("swift", &["--version"])?.stdout;
parse_swift_version(&swift_version).map(Ok)
let swift_version =
parse_swift_version(&context.exec_cmd("swift", &["--version"])?.stdout)?;
VersionFormatter::format_module_version(
module.get_name(),
&swift_version,
config.version_format,
)
.map(Ok)
}
_ => None,
})
@ -58,7 +65,7 @@ fn parse_swift_version(swift_version: &str) -> Option<String> {
// return "5.2.2" or "5.3-dev"
let version = splited.next()?;
Some(format!("v{}", version))
Some(version.to_string())
}
#[cfg(test)]
@ -72,13 +79,13 @@ mod tests {
#[test]
fn test_parse_swift_version() {
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]
fn test_parse_swift_version_without_org_name() {
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]

View File

@ -4,6 +4,7 @@ use crate::configs::terraform::TerraformConfig;
use crate::formatter::StringFormatter;
use crate::utils;
use crate::formatter::VersionFormatter;
use std::io;
use std::path::PathBuf;
@ -34,9 +35,16 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
_ => None,
})
.map(|variable| match variable {
"version" => format_terraform_version(
&context.exec_cmd("terraform", &["version"])?.stdout.as_str(),
)
"version" => {
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),
"workspace" => get_terraform_workspace(context).map(Ok),
_ => 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 v0.12.14
// 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()?
.trim_start_matches("Terraform ")
.trim()
.trim_start_matches('v')
.to_owned()
+ " ",
)
@ -99,44 +108,38 @@ mod tests {
use std::io::{self, Write};
#[test]
fn test_format_terraform_version_release() {
fn test_get_terraform_version_release() {
let input = "Terraform v0.12.14";
assert_eq!(
format_terraform_version(input),
Some("v0.12.14 ".to_string())
);
assert_eq!(get_terraform_version(input), Some("0.12.14 ".to_string()));
}
#[test]
fn test_format_terraform_version_prerelease() {
fn test_get_terraform_version_prerelease() {
let input = "Terraform v0.12.14-rc1";
assert_eq!(
format_terraform_version(input),
Some("v0.12.14-rc1 ".to_string())
get_terraform_version(input),
Some("0.12.14-rc1 ".to_string())
);
}
#[test]
fn test_format_terraform_version_development() {
fn test_get_terraform_version_development() {
let input = "Terraform v0.12.14-dev (cca89f74)";
assert_eq!(
format_terraform_version(input),
Some("v0.12.14-dev (cca89f74) ".to_string())
get_terraform_version(input),
Some("0.12.14-dev (cca89f74) ".to_string())
);
}
#[test]
fn test_format_terraform_version_multiline() {
fn test_get_terraform_version_multiline() {
let input = "Terraform v0.12.13
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
";
assert_eq!(
format_terraform_version(input),
Some("v0.12.13 ".to_string())
);
assert_eq!(get_terraform_version(input), Some("0.12.13 ".to_string()));
}
#[test]

View File

@ -2,6 +2,7 @@ use super::{Context, Module, RootModuleConfig};
use crate::configs::vagrant::VagrantConfig;
use crate::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Vagrant version
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,
})
.map(|variable| match variable {
"version" => format_vagrant_version(
&context.exec_cmd("vagrant", &["--version"])?.stdout.as_str(),
)
"version" => {
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),
_ => None,
})
@ -50,7 +57,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
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 2.2.10
let version = vagrant_stdout
@ -59,10 +66,7 @@ fn format_vagrant_version(vagrant_stdout: &str) -> Option<String> {
// return "2.2.10"
.nth(1)?;
let mut formatted_version = String::with_capacity(version.len() + 1);
formatted_version.push('v');
formatted_version.push_str(version);
Some(formatted_version)
Some(version.to_string())
}
#[cfg(test)]
@ -97,8 +101,8 @@ mod tests {
}
#[test]
fn test_format_vagrant_version() {
fn test_get_vagrant_version() {
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::formatter::StringFormatter;
use crate::formatter::VersionFormatter;
/// Creates a module with the current Zig version
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 {
"version" => {
let zig_version_output = context.exec_cmd("zig", &["version"])?.stdout;
let zig_version = format!("v{}", zig_version_output.trim());
Some(Ok(zig_version))
let zig_version = context.exec_cmd("zig", &["version"])?.stdout;
VersionFormatter::format_module_version(
module.get_name(),
&zig_version.trim(),
config.version_format,
)
.map(Ok)
}
_ => None,
})