mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
feat(pwsh): debug prompt
This commit is contained in:
parent
6e3c1af164
commit
d11c39b620
|
@ -29,10 +29,11 @@ var (
|
||||||
|
|
||||||
// printCmd represents the prompt command
|
// printCmd represents the prompt command
|
||||||
var printCmd = &cobra.Command{
|
var printCmd = &cobra.Command{
|
||||||
Use: "print [primary|secondary|transient|right|tooltip|valid|error]",
|
Use: "print [debug|primary|secondary|transient|right|tooltip|valid|error]",
|
||||||
Short: "Print the prompt/context",
|
Short: "Print the prompt/context",
|
||||||
Long: "Print one of the prompts based on the location/use-case.",
|
Long: "Print one of the prompts based on the location/use-case.",
|
||||||
ValidArgs: []string{
|
ValidArgs: []string{
|
||||||
|
"debug",
|
||||||
"primary",
|
"primary",
|
||||||
"secondary",
|
"secondary",
|
||||||
"transient",
|
"transient",
|
||||||
|
@ -86,6 +87,8 @@ var printCmd = &cobra.Command{
|
||||||
Plain: plain,
|
Plain: plain,
|
||||||
}
|
}
|
||||||
switch args[0] {
|
switch args[0] {
|
||||||
|
case "debug":
|
||||||
|
fmt.Print(eng.PrintExtraPrompt(engine.Debug))
|
||||||
case "primary":
|
case "primary":
|
||||||
fmt.Print(eng.PrintPrimary())
|
fmt.Print(eng.PrintPrimary())
|
||||||
case "secondary":
|
case "secondary":
|
||||||
|
|
|
@ -40,6 +40,7 @@ type Config struct {
|
||||||
ValidLine *ExtraPrompt `json:"valid_line,omitempty"`
|
ValidLine *ExtraPrompt `json:"valid_line,omitempty"`
|
||||||
ErrorLine *ExtraPrompt `json:"error_line,omitempty"`
|
ErrorLine *ExtraPrompt `json:"error_line,omitempty"`
|
||||||
SecondaryPrompt *ExtraPrompt `json:"secondary_prompt,omitempty"`
|
SecondaryPrompt *ExtraPrompt `json:"secondary_prompt,omitempty"`
|
||||||
|
DebugPrompt *ExtraPrompt `json:"debug_prompt,omitempty"`
|
||||||
Palette color.Palette `json:"palette,omitempty"`
|
Palette color.Palette `json:"palette,omitempty"`
|
||||||
|
|
||||||
format string
|
format string
|
||||||
|
|
|
@ -275,11 +275,14 @@ const (
|
||||||
Valid
|
Valid
|
||||||
Error
|
Error
|
||||||
Secondary
|
Secondary
|
||||||
|
Debug
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
|
func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
|
||||||
var prompt *ExtraPrompt
|
var prompt *ExtraPrompt
|
||||||
switch promptType {
|
switch promptType {
|
||||||
|
case Debug:
|
||||||
|
prompt = e.Config.DebugPrompt
|
||||||
case Transient:
|
case Transient:
|
||||||
prompt = e.Config.TransientPrompt
|
prompt = e.Config.TransientPrompt
|
||||||
case Valid:
|
case Valid:
|
||||||
|
@ -297,6 +300,8 @@ func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
|
||||||
return template
|
return template
|
||||||
}
|
}
|
||||||
switch promptType { // nolint: exhaustive
|
switch promptType { // nolint: exhaustive
|
||||||
|
case Debug:
|
||||||
|
return "[DBG]: "
|
||||||
case Transient:
|
case Transient:
|
||||||
return "{{ .Shell }}> "
|
return "{{ .Shell }}> "
|
||||||
case Secondary:
|
case Secondary:
|
||||||
|
|
|
@ -67,6 +67,11 @@ function global:Initialize-ModuleSupport {
|
||||||
$env:POSH_TRANSIENT = $false
|
$env:POSH_TRANSIENT = $false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (Test-Path variable:/PSDebugContext) {
|
||||||
|
$standardOut = @(&$omp prompt print debug --pwd="$cleanPWD" --pswd="$cleanPSWD" --config="$config" 2>&1)
|
||||||
|
$standardOut -join "`n"
|
||||||
|
return
|
||||||
|
}
|
||||||
$errorCode = 0
|
$errorCode = 0
|
||||||
Initialize-ModuleSupport
|
Initialize-ModuleSupport
|
||||||
Set-PoshContext
|
Set-PoshContext
|
||||||
|
|
Loading…
Reference in a new issue