diff --git a/docs/config/README.md b/docs/config/README.md index 056a39aa..1613eaad 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -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 diff --git a/src/configs/cmake.rs b/src/configs/cmake.rs index d225b0d9..8ba2c6a9 100644 --- a/src/configs/cmake.rs +++ b/src/configs/cmake.rs @@ -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, diff --git a/src/configs/crystal.rs b/src/configs/crystal.rs index e5b61476..ec90b773 100644 --- a/src/configs/crystal.rs +++ b/src/configs/crystal.rs @@ -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, diff --git a/src/configs/dart.rs b/src/configs/dart.rs index 94f5112e..8edb214b 100644 --- a/src/configs/dart.rs +++ b/src/configs/dart.rs @@ -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, diff --git a/src/configs/deno.rs b/src/configs/deno.rs index 39817843..cb4cddc5 100644 --- a/src/configs/deno.rs +++ b/src/configs/deno.rs @@ -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, diff --git a/src/configs/dotnet.rs b/src/configs/dotnet.rs index 05438f36..78c6d8de 100644 --- a/src/configs/dotnet.rs +++ b/src/configs/dotnet.rs @@ -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, diff --git a/src/configs/elixir.rs b/src/configs/elixir.rs index 9eb5b347..d4ed7161 100644 --- a/src/configs/elixir.rs +++ b/src/configs/elixir.rs @@ -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, diff --git a/src/configs/elm.rs b/src/configs/elm.rs index d97cddd9..34d6b626 100644 --- a/src/configs/elm.rs +++ b/src/configs/elm.rs @@ -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, diff --git a/src/configs/erlang.rs b/src/configs/erlang.rs index b0a7515e..8ab6f076 100644 --- a/src/configs/erlang.rs +++ b/src/configs/erlang.rs @@ -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, diff --git a/src/configs/go.rs b/src/configs/go.rs index c4fb3dca..0e9f2eff 100644 --- a/src/configs/go.rs +++ b/src/configs/go.rs @@ -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, diff --git a/src/configs/helm.rs b/src/configs/helm.rs index a99ad7ab..91c38efa 100644 --- a/src/configs/helm.rs +++ b/src/configs/helm.rs @@ -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, diff --git a/src/configs/julia.rs b/src/configs/julia.rs index 0ee98614..785d229d 100644 --- a/src/configs/julia.rs +++ b/src/configs/julia.rs @@ -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, diff --git a/src/configs/kotlin.rs b/src/configs/kotlin.rs index b609c033..35bbafa5 100644 --- a/src/configs/kotlin.rs +++ b/src/configs/kotlin.rs @@ -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", diff --git a/src/configs/lua.rs b/src/configs/lua.rs index a70e3018..2b8e0898 100644 --- a/src/configs/lua.rs +++ b/src/configs/lua.rs @@ -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", diff --git a/src/configs/nim.rs b/src/configs/nim.rs index bbbe90a6..936045f5 100644 --- a/src/configs/nim.rs +++ b/src/configs/nim.rs @@ -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, diff --git a/src/configs/ocaml.rs b/src/configs/ocaml.rs index fe149837..4675b59b 100644 --- a/src/configs/ocaml.rs +++ b/src/configs/ocaml.rs @@ -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, diff --git a/src/configs/perl.rs b/src/configs/perl.rs index 9aaf1ce4..ca7aed45 100644 --- a/src/configs/perl.rs +++ b/src/configs/perl.rs @@ -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![ diff --git a/src/configs/php.rs b/src/configs/php.rs index 2c44141d..bb2b8d7c 100644 --- a/src/configs/php.rs +++ b/src/configs/php.rs @@ -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"], diff --git a/src/configs/purescript.rs b/src/configs/purescript.rs index a52dff79..3d162579 100644 --- a/src/configs/purescript.rs +++ b/src/configs/purescript.rs @@ -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, diff --git a/src/configs/scala.rs b/src/configs/scala.rs index 1be54487..90adad15 100644 --- a/src/configs/scala.rs +++ b/src/configs/scala.rs @@ -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: "🆂 ", diff --git a/src/configs/swift.rs b/src/configs/swift.rs index 4e569494..c63b1ae6 100644 --- a/src/configs/swift.rs +++ b/src/configs/swift.rs @@ -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, diff --git a/src/configs/terraform.rs b/src/configs/terraform.rs index 2b56fba9..2f68ccb3 100644 --- a/src/configs/terraform.rs +++ b/src/configs/terraform.rs @@ -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, diff --git a/src/configs/vagrant.rs b/src/configs/vagrant.rs index 60460941..cc7df44b 100644 --- a/src/configs/vagrant.rs +++ b/src/configs/vagrant.rs @@ -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, diff --git a/src/configs/zig.rs b/src/configs/zig.rs index ff47889e..c26ae5b7 100644 --- a/src/configs/zig.rs +++ b/src/configs/zig.rs @@ -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, diff --git a/src/formatter/version.rs b/src/formatter/version.rs index 2b3e8aed..808fa15f 100644 --- a/src/formatter/version.rs +++ b/src/formatter/version.rs @@ -60,6 +60,20 @@ impl<'a> VersionFormatter<'a> { .collect::() }) } + + pub fn format_module_version( + module_name: &str, + version: &str, + version_format: &str, + ) -> Option { + 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)] diff --git a/src/modules/cmake.rs b/src/modules/cmake.rs index 01d4010e..5ddcb052 100644 --- a/src/modules/cmake.rs +++ b/src/modules/cmake.rs @@ -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> { _ => 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> { Some(module) } -fn format_cmake_version(cmake_version: &str) -> Option { - let version = cmake_version.split_whitespace().nth(2)?; - Some(format!("v{}", version)) +fn get_cmake_version(cmake_version: &str) -> Option { + Some( + cmake_version + //split into ["cmake" "version" "3.10.2", ...] + .split_whitespace() + // get down to "3.10.2" + .nth(2)? + .to_string(), + ) } #[cfg(test)] diff --git a/src/modules/crystal.rs b/src/modules/crystal.rs index 8049580f..d59f4f30 100644 --- a/src/modules/crystal.rs +++ b/src/modules/crystal.rs @@ -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> { @@ -30,9 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => 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> { Some(module) } -fn format_crystal_version(crystal_version: &str) -> Option { - 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 { + Some( + crystal_version + // split into ["Crystal", "0.35.1", ...] + .split_whitespace() + // return "0.35.1" + .nth(1)? + .to_string(), + ) } #[cfg(test)] diff --git a/src/modules/dart.rs b/src/modules/dart.rs index 00b4cf35..5d1b25f6 100644 --- a/src/modules/dart.rs +++ b/src/modules/dart.rs @@ -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> { @@ -31,8 +32,14 @@ pub fn module<'a>(context: &'a Context) -> Option> { }) .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> { Some(module) } -fn parse_dart_version(dart_version: &str) -> Option { - 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 { + 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()?; diff --git a/src/modules/deno.rs b/src/modules/deno.rs index 8b1fac5f..ee176116 100644 --- a/src/modules/deno.rs +++ b/src/modules/deno.rs @@ -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> { @@ -27,10 +28,16 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => 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> { Some(module) } -fn parse_deno_version(deno_version: &str) -> Option { - 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 { + 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()?; diff --git a/src/modules/dotnet.rs b/src/modules/dotnet.rs index 3234114e..09bee872 100644 --- a/src/modules/dotnet.rs +++ b/src/modules/dotnet.rs @@ -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> { } 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 { +) -> Option { 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 { +fn try_find_nearby_global_json(current_dir: &Path, repo_root: Option<&Path>) -> Option { 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 { +fn check_directory_for_global_json(path: &Path) -> Option { 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 { } } -fn get_pinned_sdk_version_from_file(path: &Path) -> Option { +fn get_pinned_sdk_version_from_file(path: &Path) -> Option { 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 { get_pinned_sdk_version(&json_text) } -fn get_pinned_sdk_version(json: &str) -> Option { +fn get_pinned_sdk_version(json: &str) -> Option { 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 { 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 { Some(value?.to_str()?.to_ascii_lowercase()) } -fn get_version_from_cli(context: &Context) -> Option { +fn get_version_from_cli(context: &Context) -> Option { 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 { +fn get_latest_sdk_from_cli(context: &Context) -> Option { match context.exec_cmd("dotnet", &["--list-sdks"]) { Some(sdks_output) => { fn parse_failed() -> Option { @@ -305,9 +309,8 @@ fn get_latest_sdk_from_cli(context: &Context) -> Option { 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] diff --git a/src/modules/elixir.rs b/src/modules/elixir.rs index fa642c08..d2b041b6 100644 --- a/src/modules/elixir.rs +++ b/src/modules/elixir.rs @@ -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> { .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(); diff --git a/src/modules/elm.rs b/src/modules/elm.rs index 7ebd848f..d3acab92 100644 --- a/src/modules/elm.rs +++ b/src/modules/elm.rs @@ -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> { @@ -32,8 +33,12 @@ pub fn module<'a>(context: &'a Context) -> Option> { .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, }) diff --git a/src/modules/erlang.rs b/src/modules/erlang.rs index 11e1d657..c5b419c3 100644 --- a/src/modules/erlang.rs +++ b/src/modules/erlang.rs @@ -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> { @@ -30,7 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => 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); diff --git a/src/modules/golang.rs b/src/modules/golang.rs index 662462de..86a4990b 100644 --- a/src/modules/golang.rs +++ b/src/modules/golang.rs @@ -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> { @@ -30,8 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option> { }) .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> { Some(module) } -fn format_go_version(go_stdout: &str) -> Option { +fn get_go_version(go_stdout: &str) -> Option { // 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 { // 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())); } } diff --git a/src/modules/helm.rs b/src/modules/helm.rs index 1b1f77b6..5da66a8f 100644 --- a/src/modules/helm.rs +++ b/src/modules/helm.rs @@ -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> { @@ -30,13 +31,19 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => 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> { Some(module) } -fn format_helm_version(helm_stdout: &str) -> Option { +fn get_helm_version(helm_stdout: &str) -> Option { // `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())); } } diff --git a/src/modules/java.rs b/src/modules/java.rs index 158eb51b..2829b98c 100644 --- a/src/modules/java.rs +++ b/src/modules/java.rs @@ -82,7 +82,7 @@ fn format_java_version(java_version: &str, version_format: &str) -> Option Some(formatted), Err(error) => { - log::warn!("Error formating `java` version:\n{}", error); + log::warn!("Error formatting `java` version:\n{}", error); Some(format!("v{}", version)) } } diff --git a/src/modules/julia.rs b/src/modules/julia.rs index 0ae892ad..05a6eb39 100644 --- a/src/modules/julia.rs +++ b/src/modules/julia.rs @@ -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> { @@ -30,10 +31,16 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => 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> { Some(module) } -fn format_julia_version(julia_stdout: &str) -> Option { +fn get_julia_version(julia_stdout: &str) -> Option { // julia version output looks like this: // julia version 1.4.0 @@ -62,7 +69,7 @@ fn format_julia_version(julia_stdout: &str) -> Option { .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())); } } diff --git a/src/modules/kotlin.rs b/src/modules/kotlin.rs index 94015fa3..74de1ae0 100644 --- a/src/modules/kotlin.rs +++ b/src/modules/kotlin.rs @@ -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[\\d\\.]+[\\d\\.]+[\\d\\.]+)"; @@ -34,11 +35,13 @@ pub fn module<'a>(context: &'a Context) -> Option> { }) .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> { fn get_kotlin_version(context: &Context, kotlin_binary: &str) -> Option { 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 { +fn parse_kotlin_version(kotlin_stdout: &str) -> Option { // 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()) ); } } diff --git a/src/modules/lua.rs b/src/modules/lua.rs index 022cae7e..8e6e9f5a 100644 --- a/src/modules/lua.rs +++ b/src/modules/lua.rs @@ -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> { @@ -30,7 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => 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 { // 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()) ); } } diff --git a/src/modules/nim.rs b/src/modules/nim.rs index f7bea7ba..9a7fc4e2 100644 --- a/src/modules/nim.rs +++ b/src/modules/nim.rs @@ -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> { @@ -33,7 +34,12 @@ pub fn module<'a>(context: &'a Context) -> Option> { .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, diff --git a/src/modules/nodejs.rs b/src/modules/nodejs.rs index b48e5d83..9ea4bc35 100644 --- a/src/modules/nodejs.rs +++ b/src/modules/nodejs.rs @@ -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) } } diff --git a/src/modules/ocaml.rs b/src/modules/ocaml.rs index 634f1bd7..6b33442e 100644 --- a/src/modules/ocaml.rs +++ b/src/modules/ocaml.rs @@ -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> { } 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, }) diff --git a/src/modules/perl.rs b/src/modules/perl.rs index 735860fc..b9e6ee02 100644 --- a/src/modules/perl.rs +++ b/src/modules/perl.rs @@ -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> { @@ -33,7 +34,12 @@ pub fn module<'a>(context: &'a Context) -> Option> { 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, }) diff --git a/src/modules/php.rs b/src/modules/php.rs index 3152c0c1..cf056c32 100644 --- a/src/modules/php.rs +++ b/src/modules/php.rs @@ -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> { @@ -30,14 +31,14 @@ pub fn module<'a>(context: &'a Context) -> Option> { }) .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> { 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()?; diff --git a/src/modules/purescript.rs b/src/modules/purescript.rs index 394eb191..9b319f9e 100644 --- a/src/modules/purescript.rs +++ b/src/modules/purescript.rs @@ -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> { @@ -31,7 +32,12 @@ pub fn module<'a>(context: &'a Context) -> Option> { .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, }) diff --git a/src/modules/python.rs b/src/modules/python.rs index ace3e965..d8354b49 100644 --- a/src/modules/python.rs +++ b/src/modules/python.rs @@ -94,7 +94,7 @@ fn format_python_version(python_version: &str, version_format: &str) -> Option Some(formatted), Err(error) => { - log::warn!("Error formating `python` version:\n{}", error); + log::warn!("Error formatting `python` version:\n{}", error); Some(format!("v{}", version)) } } diff --git a/src/modules/ruby.rs b/src/modules/ruby.rs index 26b6a3f3..f6eab6d3 100644 --- a/src/modules/ruby.rs +++ b/src/modules/ruby.rs @@ -69,7 +69,7 @@ fn format_ruby_version(ruby_version: &str, version_format: &str) -> Option Some(formatted), Err(error) => { - log::warn!("Error formating `ruby` version:\n{}", error); + log::warn!("Error formatting `ruby` version:\n{}", error); Some(format!("v{}", version)) } } diff --git a/src/modules/rust.rs b/src/modules/rust.rs index a465d979..8026b3c4 100644 --- a/src/modules/rust.rs +++ b/src/modules/rust.rs @@ -213,7 +213,7 @@ fn format_rustc_version(rustc_version: &str, version_format: &str) -> Option Some(formatted), Err(error) => { - log::warn!("Error formating `rust` version:\n{}", error); + log::warn!("Error formatting `rust` version:\n{}", error); Some(format!("v{}", version)) } } diff --git a/src/modules/scala.rs b/src/modules/scala.rs index 16290aee..b88d5684 100644 --- a/src/modules/scala.rs +++ b/src/modules/scala.rs @@ -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> { let mut module = context.new_module("scala"); @@ -31,7 +32,12 @@ pub fn module<'a>(context: &'a Context) -> Option> { .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 { // 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()) ); } diff --git a/src/modules/swift.rs b/src/modules/swift.rs index 5ff5d6f9..13d36ce5 100644 --- a/src/modules/swift.rs +++ b/src/modules/swift.rs @@ -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> { @@ -31,8 +32,14 @@ pub fn module<'a>(context: &'a Context) -> Option> { }) .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 { // 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] diff --git a/src/modules/terraform.rs b/src/modules/terraform.rs index c051abb9..006c234f 100644 --- a/src/modules/terraform.rs +++ b/src/modules/terraform.rs @@ -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> { _ => 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 { } } -fn format_terraform_version(version: &str) -> Option { +fn get_terraform_version(version: &str) -> Option { // `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 { .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] diff --git a/src/modules/vagrant.rs b/src/modules/vagrant.rs index 06ebef75..8ff6b6fe 100644 --- a/src/modules/vagrant.rs +++ b/src/modules/vagrant.rs @@ -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> { @@ -30,9 +31,15 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => 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> { Some(module) } -fn format_vagrant_version(vagrant_stdout: &str) -> Option { +fn get_vagrant_version(vagrant_stdout: &str) -> Option { // `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 { // 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())); } } diff --git a/src/modules/zig.rs b/src/modules/zig.rs index 8c7d543b..2b974868 100644 --- a/src/modules/zig.rs +++ b/src/modules/zig.rs @@ -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> { @@ -31,9 +32,13 @@ pub fn module<'a>(context: &'a Context) -> Option> { }) .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, })