mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
feat(project): add always_enabled and project type
This commit is contained in:
parent
8aca8a2d84
commit
07206e5aae
|
@ -20,18 +20,12 @@ type ProjectItem struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProjectData struct {
|
type ProjectData struct {
|
||||||
|
Type string
|
||||||
Version string
|
Version string
|
||||||
Name string
|
Name string
|
||||||
Target string
|
Target string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProjectData) enabled() bool {
|
|
||||||
if p == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return len(p.Version) > 0 || len(p.Name) > 0 || len(p.Target) > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rust Cargo package
|
// Rust Cargo package
|
||||||
type CargoTOML struct {
|
type CargoTOML struct {
|
||||||
Package ProjectData
|
Package ProjectData
|
||||||
|
@ -72,10 +66,11 @@ func (n *Project) Enabled() bool {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
n.ProjectData = *data
|
n.ProjectData = *data
|
||||||
return n.enabled()
|
n.ProjectData.Type = item.Name
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return n.props.GetBool(properties.AlwaysEnabled, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Project) Template() string {
|
func (n *Project) Template() string {
|
||||||
|
|
|
@ -155,19 +155,21 @@ func TestPackage(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Case: "Empty project package node.js",
|
Case: "Empty project package node.js",
|
||||||
ExpectedEnabled: false,
|
ExpectedEnabled: true,
|
||||||
Name: "node",
|
Name: "node",
|
||||||
File: "package.json",
|
File: "package.json",
|
||||||
PackageContents: "{}",
|
PackageContents: "{}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Case: "Empty project package cargo",
|
Case: "Empty project package cargo",
|
||||||
|
ExpectedEnabled: true,
|
||||||
Name: "cargo",
|
Name: "cargo",
|
||||||
File: "Cargo.toml",
|
File: "Cargo.toml",
|
||||||
PackageContents: "",
|
PackageContents: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Case: "Empty project package poetry",
|
Case: "Empty project package poetry",
|
||||||
|
ExpectedEnabled: true,
|
||||||
Name: "poetry",
|
Name: "poetry",
|
||||||
File: "pyproject.toml",
|
File: "pyproject.toml",
|
||||||
PackageContents: "",
|
PackageContents: "",
|
||||||
|
@ -263,7 +265,7 @@ func TestNuspecPackage(t *testing.T) {
|
||||||
Case: "no info in file",
|
Case: "no info in file",
|
||||||
FileName: "../test/empty.nuspec",
|
FileName: "../test/empty.nuspec",
|
||||||
HasFiles: true,
|
HasFiles: true,
|
||||||
ExpectedEnabled: false,
|
ExpectedEnabled: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Case: "no files",
|
Case: "no files",
|
||||||
|
|
|
@ -18,6 +18,12 @@ Supports:
|
||||||
- .NET project (`*.csproj`, `*.vbproj` or `*.fsproj`, first file match info is displayed)
|
- .NET project (`*.csproj`, `*.vbproj` or `*.fsproj`, first file match info is displayed)
|
||||||
- Julia project (`JuliaProject.toml`, `Project.toml`)
|
- Julia project (`JuliaProject.toml`, `Project.toml`)
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---------------- | --------- | --------------------------------------------- |
|
||||||
|
| `always_enabled` | `boolean` | always show the segment - defaults to `false` |
|
||||||
|
|
||||||
## Sample Configuration
|
## Sample Configuration
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
@ -43,11 +49,12 @@ Supports:
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ---------- | -------- | ------------------------------------------------------ |
|
| ---------- | -------- | ------------------------------------------------------------------------------------- |
|
||||||
| `.Version` | `string` | The version of your project |
|
| `.Type` | `string` | The type of project (`node`, `cargo`, `poetry`, `php`, `nuspec`, `dotnet` or `julia`) |
|
||||||
| `.Target` | `string` | The target framwork/language version of your project |
|
| `.Version` | `string` | The version of your project |
|
||||||
| `.Name` | `string` | The name of your project |
|
| `.Target` | `string` | The target framwork/language version of your project |
|
||||||
| `.Error` | `string` | The error context when we can't fetch the project info |
|
| `.Name` | `string` | The name of your project |
|
||||||
|
| `.Error` | `string` | The error context when we can't fetch the project info |
|
||||||
|
|
||||||
[templates]: /docs/configuration/templates
|
[templates]: /docs/configuration/templates
|
||||||
|
|
Loading…
Reference in a new issue