color fixes--all good now

This commit is contained in:
Dane Schneider
2024-03-16 00:10:52 -07:00
parent 9689938ea4
commit 2a3256f7c5
24 changed files with 133 additions and 81 deletions

View File

@@ -119,7 +119,7 @@ func SelectOrSignInOrCreate() error {
return fmt.Errorf("error setting auth: %v", err)
}
fmt.Printf("✅ Signed in as %s | Org: %s\n", color.New(color.Bold, color.FgHiGreen).Sprintf("<%s> %s", Current.UserName, Current.Email), color.New(color.FgHiCyan).Sprint(Current.OrgName))
fmt.Printf("✅ Signed in as %s | Org: %s\n", color.New(color.Bold, term.ColorHiGreen).Sprintf("<%s> %s", Current.UserName, Current.Email), color.New(term.ColorHiCyan).Sprint(Current.OrgName))
fmt.Println()
term.PrintCmds("", "new", "plans")

View File

@@ -2,6 +2,7 @@ package changes_tui
import (
"fmt"
"plandex/term"
"github.com/charmbracelet/lipgloss"
"github.com/fatih/color"
@@ -120,7 +121,7 @@ func (m changesUIModel) renderMainViewFooter() string {
Foreground(lipgloss.Color(helpTextColor))
var footer string
if m.didCopy {
footer = color.New(color.Bold, color.FgHiCyan).Sprint(` copied to clipboard`)
footer = color.New(color.Bold, term.ColorHiCyan).Sprint(` copied to clipboard`)
} else {
footer = ` (c)opy change to clipboard • (r)eject file`
}

View File

@@ -1,6 +1,7 @@
package changes_tui
import (
"plandex/term"
"strings"
"github.com/charmbracelet/lipgloss"
@@ -28,7 +29,7 @@ func (m changesUIModel) renderPathTabs() string {
tab := " 📄 " + path + " "
pathColor := color.FgHiGreen
pathColor := term.ColorHiGreen
bgColor := color.BgGreen
if selected {

View File

@@ -1,6 +1,7 @@
package changes_tui
import (
"plandex/term"
"strings"
"github.com/fatih/color"
@@ -89,7 +90,7 @@ func (m changesUIModel) getReplacementOldDisplay() oldReplacementRes {
oldContentLines := strings.Split(oldContent, "\n")
for i, line := range oldContentLines {
oldContentLines[i] = color.New(color.FgHiRed).Sprint(line)
oldContentLines[i] = color.New(term.ColorHiRed).Sprint(line)
}
oldContent = strings.Join(oldContentLines, "\n")
@@ -123,7 +124,7 @@ func (m changesUIModel) getReplacementNewDisplay(prependContent, appendContent s
newContentLines := strings.Split(newContent, "\n")
for i, line := range newContentLines {
newContentLines[i] = color.New(color.FgHiGreen).Sprint(line)
newContentLines[i] = color.New(term.ColorHiGreen).Sprint(line)
}
newContent = strings.Join(newContentLines, "\n")

View File

@@ -1,6 +1,7 @@
package changes_tui
import (
"plandex/term"
"strings"
"github.com/charmbracelet/lipgloss"
@@ -30,7 +31,7 @@ func (m changesUIModel) renderSidebar() string {
if m.hasNewFile() && i == 0 {
createdFile = true
selected := m.selectedNewFile()
fgColor := color.FgHiGreen
fgColor := term.ColorHiGreen
bgColor := color.BgGreen
icon := "🌟"
@@ -58,10 +59,10 @@ func (m changesUIModel) renderSidebar() string {
selected := currentRep != nil && rep.Id == currentRep.Id
s := ""
fgColor := color.FgHiGreen
fgColor := term.ColorHiGreen
bgColor := color.BgGreen
if rep.Failed {
fgColor = color.FgHiRed
fgColor = term.ColorHiRed
bgColor = color.BgRed
anyFailed = true
} else if rep.RejectedAt != nil {
@@ -98,10 +99,10 @@ func (m changesUIModel) renderSidebar() string {
}
if anyApplied {
fgColor := color.FgHiGreen
fgColor := term.ColorHiGreen
bgColor := color.BgGreen
if anyFailed {
fgColor = color.FgHiRed
fgColor = term.ColorHiRed
bgColor = color.BgRed
}

View File

@@ -1,6 +1,7 @@
package changes_tui
import (
"plandex/term"
"strings"
"github.com/charmbracelet/bubbles/viewport"
@@ -219,8 +220,8 @@ func (m changesUIModel) renderConfirmRejectFile() string {
style := lipgloss.NewStyle().Padding(1).BorderStyle(lipgloss.NormalBorder()).BorderForeground(lipgloss.Color(borderColor)).Width(m.width - 2).Height(m.height - 2)
prompt := color.New(color.Bold).Sprintf("🧐 Are you sure you want to reject changes to ") +
color.New(color.Bold, color.FgHiMagenta).Sprint(m.selectionInfo.currentPath) + "?\n\n" +
color.New(color.FgHiCyan, color.Bold).Sprintf("(y)es | (n)o")
color.New(color.Bold, term.ColorHiMagenta).Sprint(m.selectionInfo.currentPath) + "?\n\n" +
color.New(term.ColorHiCyan, color.Bold).Sprintf("(y)es | (n)o")
return style.Render(prompt)
}

View File

@@ -75,7 +75,7 @@ func checkout(cmd *cobra.Command, args []string) {
}
if branchName == "" {
fmt.Printf("🌱 Branch %s not found\n", color.New(color.Bold, color.FgHiCyan).Sprint(nameOrIdx))
fmt.Printf("🌱 Branch %s not found\n", color.New(color.Bold, term.ColorHiCyan).Sprint(nameOrIdx))
res, err := term.ConfirmYesNo("Create it now?")
if err != nil {
@@ -132,7 +132,7 @@ func checkout(cmd *cobra.Command, args []string) {
return
}
// fmt.Printf("✅ Created branch %s\n", color.New(color.Bold, color.FgHiGreen).Sprint(branchName))
// fmt.Printf("✅ Created branch %s\n", color.New(color.Bold, term.ColorHiGreen).Sprint(branchName))
}
err := lib.WriteCurrentBranch(branchName)
@@ -142,7 +142,7 @@ func checkout(cmd *cobra.Command, args []string) {
return
}
fmt.Printf("✅ Checked out branch %s\n", color.New(color.Bold, color.FgHiGreen).Sprint(branchName))
fmt.Printf("✅ Checked out branch %s\n", color.New(color.Bold, term.ColorHiGreen).Sprint(branchName))
fmt.Println()
term.PrintCmds("", "load", "tell", "branches", "delete-branch")

View File

@@ -86,7 +86,7 @@ func convo(cmd *cobra.Command, args []string) {
totalTokens += msg.Tokens
}
convo = strings.ReplaceAll(convo, stoppedEarlyMsg, color.New(color.FgHiRed).Sprint(stoppedEarlyMsg))
convo = strings.ReplaceAll(convo, stoppedEarlyMsg, color.New(term.ColorHiRed).Sprint(stoppedEarlyMsg))
output :=
fmt.Sprintf("\n%s", convo) +

View File

@@ -110,7 +110,7 @@ func deleteBranch(cmd *cobra.Command, args []string) {
}
if !found {
fmt.Printf("🤷‍♂️ Branch %s does not exist\n", color.New(color.Bold, color.FgHiCyan).Sprint(branch))
fmt.Printf("🤷‍♂️ Branch %s does not exist\n", color.New(color.Bold, term.ColorHiCyan).Sprint(branch))
return
}
@@ -123,7 +123,7 @@ func deleteBranch(cmd *cobra.Command, args []string) {
return
}
fmt.Printf("✅ Deleted branch %s\n", color.New(color.Bold, color.FgHiCyan).Sprint(branch))
fmt.Printf("✅ Deleted branch %s\n", color.New(color.Bold, term.ColorHiCyan).Sprint(branch))
fmt.Println()
term.PrintCmds("", "branches")

View File

@@ -124,7 +124,7 @@ func del(cmd *cobra.Command, args []string) {
}
}
fmt.Printf("✅ Deleted plan %s\n", color.New(color.Bold, color.FgHiCyan).Sprint(plan.Name))
fmt.Printf("✅ Deleted plan %s\n", color.New(color.Bold, term.ColorHiCyan).Sprint(plan.Name))
}
func delAll() {

View File

@@ -69,7 +69,7 @@ func listContext(cmd *cobra.Command, args []string) {
tokensTbl := tablewriter.NewWriter(os.Stdout)
tokensTbl.SetAutoWrapText(false)
tokensTbl.Append([]string{color.New(color.FgHiCyan, color.Bold).Sprintf("Total tokens →") + color.New(color.Bold).Sprintf(" %d 🪙", totalTokens)})
tokensTbl.Append([]string{color.New(term.ColorHiCyan, color.Bold).Sprintf("Total tokens →") + color.New(color.Bold).Sprintf(" %d 🪙", totalTokens)})
tokensTbl.Render()

View File

@@ -43,7 +43,7 @@ func models(cmd *cobra.Command, args []string) {
modelSet = &shared.DefaultModelSet
}
color.New(color.Bold, color.FgHiCyan).Println("🤖 Models")
color.New(color.Bold, term.ColorHiCyan).Println("🤖 Models")
table := tablewriter.NewWriter(os.Stdout)
table.SetAutoWrapText(false)
table.SetHeader([]string{"Role", "Provider", "Model", "Temperature", "Top P"})
@@ -68,7 +68,7 @@ func models(cmd *cobra.Command, args []string) {
fmt.Println()
color.New(color.Bold, color.FgHiCyan).Println("🧠 Planner Defaults")
color.New(color.Bold, term.ColorHiCyan).Println("🧠 Planner Defaults")
table = tablewriter.NewWriter(os.Stdout)
table.SetAutoWrapText(false)
table.SetHeader([]string{"Max Tokens", "Max Convo Tokens", "Reserved Output Tokens"})
@@ -80,7 +80,7 @@ func models(cmd *cobra.Command, args []string) {
table.Render()
fmt.Println()
color.New(color.Bold, color.FgHiCyan).Println("⚙️ Planner Overrides")
color.New(color.Bold, term.ColorHiCyan).Println("⚙️ Planner Overrides")
table = tablewriter.NewWriter(os.Stdout)
table.SetAutoWrapText(false)
table.SetHeader([]string{"Name", "Value"})

View File

@@ -72,7 +72,7 @@ func new(cmd *cobra.Command, args []string) {
name = "draft"
}
fmt.Printf("✅ Started new plan %s and set it to current plan\n", color.New(color.Bold, color.FgHiGreen).Sprint(name))
fmt.Printf("✅ Started new plan %s and set it to current plan\n", color.New(color.Bold, term.ColorHiGreen).Sprint(name))
fmt.Println()
term.PrintCmds("", "load", "tell", "plans", "current")

View File

@@ -160,19 +160,19 @@ func plans(cmd *cobra.Command, args []string) {
currentProjectPlans := plansByProjectId[lib.CurrentProjectId]
if len(parentProjectIdsWithPaths) > 0 || len(childProjectIdsWithPaths) > 0 {
color.New(color.Bold, color.FgHiGreen).Print("Plans in current directory\n")
color.New(color.Bold, term.ColorHiGreen).Print("Plans in current directory\n")
} else {
fmt.Println()
}
for i, p := range currentProjectPlans {
num := strconv.Itoa(i + 1)
if p.Id == lib.CurrentPlanId {
num = color.New(color.Bold, color.FgHiGreen).Sprint(num)
num = color.New(color.Bold, term.ColorHiGreen).Sprint(num)
}
var name string
if p.Id == lib.CurrentPlanId {
name = color.New(color.Bold, color.FgHiGreen).Sprint(p.Name) + fmt.Sprint(" 👈")
name = color.New(color.Bold, term.ColorHiGreen).Sprint(p.Name) + fmt.Sprint(" 👈")
} else {
name = p.Name
}
@@ -206,12 +206,8 @@ func plans(cmd *cobra.Command, args []string) {
}
table.Render()
fmt.Println()
term.PrintCmds("", "new", "cd", "delete-plan")
} else {
fmt.Println("🤷‍♂️ No plans in current directory")
fmt.Println()
term.PrintCmds("", "new")
}
var addPathToTreeFn func(tree treeprint.Tree, basePath, localPath, projectId string, isParent bool)
@@ -262,15 +258,23 @@ func plans(cmd *cobra.Command, args []string) {
plans := plansByProjectId[projectId]
for _, p := range plans {
branch.AddNode(color.New(color.FgHiCyan).Sprint(p.Name))
branch.AddNode(color.New(term.ColorHiCyan).Sprint(p.Name))
}
}
}
var c color.Attribute
if term.IsDarkBg {
c = color.FgWhite
} else {
c = color.FgBlack
}
if len(parentProjectIdsWithPaths) > 0 {
fmt.Println()
color.New(color.Bold).Println("Plans in parent directories")
fmt.Println("cd into a directory to work on a plan in that directory")
color.New(c).Println("cd into a directory to work on a plan in that directory")
parentTree := treeprint.NewWithRoot("~")
for i := len(parentProjectIdsWithPaths) - 1; i >= 0; i-- {
@@ -290,7 +294,7 @@ func plans(cmd *cobra.Command, args []string) {
if len(childProjectIdsWithPaths) > 0 {
fmt.Println()
color.New(color.Bold).Println("Plans in child directories")
fmt.Println("cd into a directory to work on a plan in that directory")
color.New(c).Println("cd into a directory to work on a plan in that directory")
childTree := treeprint.New()
for _, p := range childProjectIdsWithPaths {
rel, err := filepath.Rel(fs.Cwd, p[0])
@@ -305,4 +309,11 @@ func plans(cmd *cobra.Command, args []string) {
} else {
fmt.Println()
}
fmt.Println()
if len(currentProjectPlanIds) > 0 {
term.PrintCmds("", "new", "cd", "delete-plan")
} else {
term.PrintCmds("", "new")
}
}

View File

@@ -25,7 +25,7 @@ func checkContextConflicts(filesByPath map[string]string) (bool, error) {
if len(conflictedPaths) > 0 {
term.StopSpinner()
color.New(color.Bold, color.FgHiYellow).Println("⚠️ Some updates conflict with pending changes:")
color.New(color.Bold, term.ColorHiYellow).Println("⚠️ Some updates conflict with pending changes:")
for path := range conflictedPaths {
fmt.Println("📄 " + path)
}

View File

@@ -80,7 +80,7 @@ func MustCheckOutdatedContext(cancelOpt, quiet bool, maybeContexts []*shared.Con
if len(outdatedRes.UpdatedContexts) == 1 {
phrase = "has been"
}
color.New(color.FgHiCyan, color.Bold).Printf("%s in context %s modified 👇\n\n", msg, phrase)
color.New(term.ColorHiCyan, color.Bold).Printf("%s in context %s modified 👇\n\n", msg, phrase)
tableString := tableForContextOutdated(outdatedRes)
fmt.Println(tableString)

View File

@@ -44,8 +44,8 @@ func resolveProject(mustResolve, shouldCreate bool) {
if (fs.PlandexDir == "" || fs.ProjectRoot == "") && mustResolve {
fmt.Printf(
"🤷‍♂️ No plans in current directory\nTry %s to create a plan or %s to see plans in nearby directories\n",
color.New(color.Bold, color.FgHiCyan).Sprint("plandex new"),
color.New(color.Bold, color.FgHiCyan).Sprint("plandex plans"))
color.New(color.Bold, term.ColorHiCyan).Sprint("plandex new"),
color.New(color.Bold, term.ColorHiCyan).Sprint("plandex plans"))
os.Exit(0)
}

View File

@@ -5,6 +5,8 @@ import (
"sort"
"strings"
"plandex/term"
"github.com/charmbracelet/lipgloss"
"github.com/fatih/color"
)
@@ -156,7 +158,7 @@ func (m streamUIModel) doRenderBuild(outputStatic bool) string {
func (m streamUIModel) renderMissingFilePrompt() string {
style := lipgloss.NewStyle().Padding(1).BorderStyle(lipgloss.NormalBorder()).BorderForeground(lipgloss.Color(borderColor)).Width(m.width - 2).Height(m.height - 2)
prompt := "📄 " + color.New(color.Bold, color.FgHiYellow).Sprint(m.missingFilePath) + " isn't in context."
prompt := "📄 " + color.New(color.Bold, term.ColorHiYellow).Sprint(m.missingFilePath) + " isn't in context."
prompt += "\n\n"
@@ -169,11 +171,11 @@ func (m streamUIModel) renderMissingFilePrompt() string {
prompt += strings.Join(words, " ")
prompt += "\n\n" + color.New(color.FgHiMagenta, color.Bold).Sprintln("🧐 What do you want to do?")
prompt += "\n\n" + color.New(term.ColorHiMagenta, color.Bold).Sprintln("🧐 What do you want to do?")
for i, opt := range missingFileSelectOpts {
if i == m.missingFileSelectedIdx {
prompt += color.New(color.FgHiCyan, color.Bold).Sprint(" > " + opt)
prompt += color.New(term.ColorHiCyan, color.Bold).Sprint(" > " + opt)
} else {
prompt += " " + opt
}

34
app/cli/term/color.go Normal file
View File

@@ -0,0 +1,34 @@
package term
import (
"github.com/fatih/color"
"github.com/muesli/termenv"
)
var IsDarkBg = termenv.HasDarkBackground()
var ColorHiGreen color.Attribute
var ColorHiMagenta color.Attribute
var ColorHiRed color.Attribute
var ColorHiYellow color.Attribute
var ColorHiCyan color.Attribute
var ColorHiBlue color.Attribute
func init() {
if IsDarkBg {
ColorHiGreen = color.FgHiGreen
ColorHiMagenta = color.FgHiMagenta
ColorHiRed = color.FgHiRed
ColorHiYellow = color.FgHiYellow
ColorHiCyan = color.FgHiCyan
ColorHiBlue = color.FgHiBlue
} else {
ColorHiGreen = color.FgGreen
ColorHiMagenta = color.FgMagenta
ColorHiRed = color.FgRed
ColorHiYellow = color.FgYellow
ColorHiCyan = color.FgCyan
ColorHiBlue = color.FgBlue
}
}

View File

@@ -10,13 +10,13 @@ import (
)
func OutputNoApiKeyMsgAndExit() {
fmt.Fprintln(os.Stderr, color.New(color.Bold, color.FgHiRed).Sprintln("\n🚨 OPENAI_API_KEY environment variable is not set.")+color.New().Sprintln("\nSet it with:\n\nexport OPENAI_API_KEY=your-api-key\n\nThen try again.\n\n👉 If you don't have an OpenAI account, sign up here → https://platform.openai.com/signup\n\n🔑 Generate an api key here → https://platform.openai.com/api-keys"))
fmt.Fprintln(os.Stderr, color.New(color.Bold, ColorHiRed).Sprintln("\n🚨 OPENAI_API_KEY environment variable is not set.")+color.New().Sprintln("\nSet it with:\n\nexport OPENAI_API_KEY=your-api-key\n\nThen try again.\n\n👉 If you don't have an OpenAI account, sign up here → https://platform.openai.com/signup\n\n🔑 Generate an api key here → https://platform.openai.com/api-keys"))
os.Exit(1)
}
func OutputSimpleError(msg string, args ...interface{}) {
msg = fmt.Sprintf(msg, args...)
fmt.Fprintln(os.Stderr, color.New(color.FgHiRed, color.Bold).Sprint("🚨 "+shared.Capitalize(msg)))
fmt.Fprintln(os.Stderr, color.New(ColorHiRed, color.Bold).Sprint("🚨 "+shared.Capitalize(msg)))
}
func OutputErrorAndExit(msg string, args ...interface{}) {
@@ -41,16 +41,16 @@ func OutputErrorAndExit(msg string, args ...interface{}) {
s := shared.Capitalize(part)
if i == 0 {
s = color.New(color.FgHiRed, color.Bold).Sprint("🚨 " + s)
s = color.New(ColorHiRed, color.Bold).Sprint("🚨 " + s)
}
displayMsg += s
}
} else {
displayMsg = color.New(color.FgHiRed, color.Bold).Sprint("🚨 " + msg)
displayMsg = color.New(ColorHiRed, color.Bold).Sprint("🚨 " + msg)
}
fmt.Fprintln(os.Stderr, color.New(color.FgHiRed, color.Bold).Sprint(displayMsg))
fmt.Fprintln(os.Stderr, color.New(ColorHiRed, color.Bold).Sprint(displayMsg))
os.Exit(1)
}

View File

@@ -43,7 +43,7 @@ var CmdDesc = map[string][2]string{
}
func PrintCmds(prefix string, cmds ...string) {
printCmds(os.Stderr, prefix, []color.Attribute{color.Bold, color.FgHiWhite, color.BgCyan}, cmds...)
printCmds(os.Stderr, prefix, []color.Attribute{color.Bold, color.FgHiWhite, color.BgCyan, color.FgHiWhite}, cmds...)
}
func PrintCmdsWithColors(prefix string, colors []color.Attribute, cmds ...string) {
@@ -80,7 +80,7 @@ func printCmds(w io.Writer, prefix string, colors []color.Attribute, cmds ...str
func PrintCustomCmd(prefix, cmd, alias, desc string) {
cmd = strings.Replace(cmd, alias, fmt.Sprintf("(%s)", alias), 1)
// desc += color.New(color.FgWhite).Sprintf(" • alias → %s", color.New(color.Bold).Sprint(alias))
styled := color.New(color.Bold, color.FgHiWhite, color.BgCyan).Sprintf(" plandex %s ", cmd)
styled := color.New(color.Bold, color.FgHiWhite, color.BgCyan, color.FgHiWhite).Sprintf(" plandex %s ", cmd)
fmt.Printf("%s%s 👉 %s\n", prefix, styled, desc)
}
@@ -88,57 +88,57 @@ func PrintCustomCmd(prefix, cmd, alias, desc string) {
func PrintCustomHelp() {
builder := &strings.Builder{}
color.New(color.Bold, color.BgGreen).Fprintln(builder, " Usage ")
color.New(color.Bold, color.BgGreen, color.FgHiWhite).Fprintln(builder, " Usage ")
color.New(color.Bold).Fprintln(builder, " plandex [command] [flags]")
color.New(color.Bold).Fprintln(builder, " pdx [command] [flags]")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgGreen).Fprintln(builder, " Help ")
color.New(color.Bold, color.BgGreen, color.FgHiWhite).Fprintln(builder, " Help ")
color.New(color.Bold).Fprintln(builder, " plandex help")
color.New(color.Bold).Fprintln(builder, " plandex [command] --help")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgMagenta).Fprintln(builder, " Getting Started ")
fmt.Fprintf(builder, " Create a new plan in your project's root directory with %s\n\n", color.New(color.Bold, color.BgCyan).Sprint(" plandex new "))
color.New(color.Bold, color.BgMagenta, color.FgHiWhite).Fprintln(builder, " Getting Started ")
fmt.Fprintf(builder, " Create a new plan in your project's root directory with %s\n\n", color.New(color.Bold, color.BgCyan, color.FgHiWhite).Sprint(" plandex new "))
color.New(color.Bold, color.BgMagenta).Fprintln(builder, " Key Commands ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiMagenta}, "new", "load", "tell", "changes", "apply")
color.New(color.Bold, color.BgMagenta, color.FgHiWhite).Fprintln(builder, " Key Commands ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiMagenta}, "new", "load", "tell", "changes", "apply")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan).Fprintln(builder, " Plans ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiCyan}, "new", "plans", "cd", "current", "delete-plan")
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Plans ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "new", "plans", "cd", "current", "delete-plan")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan).Fprintln(builder, " Changes ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiCyan}, "changes", "apply")
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Changes ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "changes", "apply")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan).Fprintln(builder, " Context ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiCyan}, "load", "ls", "rm", "update", "clear")
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Context ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "load", "ls", "rm", "update", "clear")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan).Fprintln(builder, " Branches ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiCyan}, "branches", "checkout", "delete-branch")
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Branches ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "branches", "checkout", "delete-branch")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan).Fprintln(builder, " History ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiCyan}, "convo", "log", "rewind")
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " History ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "convo", "log", "rewind")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan).Fprintln(builder, " Control ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiCyan}, "tell", "continue", "build")
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Control ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "tell", "continue", "build")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan).Fprintln(builder, " Streams ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiCyan}, "ps", "connect", "stop")
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Streams ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "ps", "connect", "stop")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan).Fprintln(builder, " AI Models ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiCyan}, "models", "set-model")
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " AI Models ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "models", "set-model")
fmt.Fprintln(builder)
color.New(color.Bold, color.BgCyan).Fprintln(builder, " Accounts ")
printCmds(builder, " ", []color.Attribute{color.Bold, color.FgHiCyan}, "sign-in")
color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Accounts ")
printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "sign-in")
fmt.Fprintln(builder)
fmt.Print(builder.String())

View File

@@ -47,8 +47,8 @@ func GetUserKeyInput() (rune, error) {
}
func ConfirmYesNo(fmtStr string, fmtArgs ...interface{}) (bool, error) {
color.New(color.FgHiMagenta, color.Bold).Printf(fmtStr+" (y)es | (n)o", fmtArgs...)
color.New(color.FgHiMagenta, color.Bold).Print("> ")
color.New(ColorHiMagenta, color.Bold).Printf(fmtStr+" (y)es | (n)o", fmtArgs...)
color.New(ColorHiMagenta, color.Bold).Print("> ")
char, err := GetUserKeyInput()
if err != nil {
@@ -62,14 +62,14 @@ func ConfirmYesNo(fmtStr string, fmtArgs ...interface{}) (bool, error) {
return false, nil
} else {
fmt.Println()
color.New(color.FgHiRed, color.Bold).Print("Invalid input.\nEnter 'y' for yes or 'n' for no.\n\n")
color.New(ColorHiRed, color.Bold).Print("Invalid input.\nEnter 'y' for yes or 'n' for no.\n\n")
return ConfirmYesNo(fmtStr, fmtArgs...)
}
}
func ConfirmYesNoCancel(fmtStr string, fmtArgs ...interface{}) (bool, bool, error) {
color.New(color.FgHiMagenta, color.Bold).Printf(fmtStr+" (y)es | (n)o | (c)ancel", fmtArgs...)
color.New(color.FgHiMagenta, color.Bold).Print("> ")
color.New(ColorHiMagenta, color.Bold).Printf(fmtStr+" (y)es | (n)o | (c)ancel", fmtArgs...)
color.New(ColorHiMagenta, color.Bold).Print("> ")
char, err := GetUserKeyInput()
if err != nil {
@@ -85,7 +85,7 @@ func ConfirmYesNoCancel(fmtStr string, fmtArgs ...interface{}) (bool, bool, erro
return false, true, nil
} else {
fmt.Println()
color.New(color.FgHiRed, color.Bold).Print("Invalid input.\nEnter 'y' for yes, 'n' for no, or 'c' for cancel.\n\n")
color.New(ColorHiRed, color.Bold).Print("Invalid input.\nEnter 'y' for yes, 'n' for no, or 'c' for cancel.\n\n")
return ConfirmYesNoCancel(fmtStr, fmtArgs...)
}
}

View File

@@ -11,7 +11,7 @@ import (
func SelectFromList(msg string, options []string) (string, error) {
var selected string
prompt := &survey.Select{
Message: color.New(color.FgHiMagenta, color.Bold).Sprint(msg),
Message: color.New(ColorHiMagenta, color.Bold).Sprint(msg),
Options: convertToStringSlice(options),
FilterMessage: "",
}

View File

@@ -62,8 +62,8 @@ func checkForUpgrade() {
if latestVersion.GreaterThan(currentVersion) {
term.StopSpinner()
fmt.Println("A new version of Plandex is available:", color.New(color.Bold, color.FgHiGreen).Sprint(versionStr))
fmt.Printf("Current version: %s\n", color.New(color.Bold, color.FgHiCyan).Sprint(version.Version))
fmt.Println("A new version of Plandex is available:", color.New(color.Bold, term.ColorHiGreen).Sprint(versionStr))
fmt.Printf("Current version: %s\n", color.New(color.Bold, term.ColorHiCyan).Sprint(version.Version))
confirmed, err := term.ConfirmYesNo("Upgrade to the latest version?")
if err != nil {
log.Println("Error reading input:", err)