Skip to content

Commit

Permalink
Update colors for giving more proper ui & ux design
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemkosk committed Jun 14, 2024
1 parent 180c8db commit 10e6110
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

var editCdm = &cobra.Command{
Use: "edit",
Short: "edit environment variables across projects",
Short: "Edit environment variables across projects. Using this, you can find all env files according to key and value and change them automatically with a single action.",
Long: `This command provides multiple editing opportunities within the given env keys and values.`,
Run: func(cmd *cobra.Command, args []string) {
command.CommandFactory(config.EDIT, "").Execute(cmd, args)
Expand Down
35 changes: 31 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,51 @@
package cmd

import (
"fmt"
"os"

config "github.com/erdemkosk/envolve-go/internal"
"github.com/erdemkosk/envolve-go/internal/logic"
"github.com/erdemkosk/envolve-go/internal/util"
"github.com/spf13/cobra"
)

var (
mainColor = util.TcellColorToAnsi(config.MAIN_COLOR)
)

type Command interface {
Execute(cmd *cobra.Command, args []string)
}

var rootCmd = &cobra.Command{
Use: "envolve",
Short: "Envolve CLI is a tool for effortless .env file management.",
Long: `Envolve is your solution for effortless .env file management.
With Envolve, you can seamlessly gather, arrange, and fine-tune environment variables
across all your projects, ensuring that your configuration data is always at your fingertips
without the risk of loss.`,
Long: ` ` + mainColor + `Envolve ` + config.RESET + ` is your solution for effortless .env file management. With ` + mainColor + `Envolve ` + config.RESET + `,you can seamlessly gather, arrange, and fine-tune environment variables
across all your projects, ensuring that your configuration data is always at your fingertips without the risk of loss. `,
}

var customHelpTemplate = fmt.Sprintf(`{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}{{end}}
Usage:
` + mainColor + `{{.UseLine}}{{if .HasAvailableSubCommands}} ` + config.RESET + `
` + config.PASTEL_RED + `Warning:
If you have not synchronized any of your projects, everything will be shown as an empty folder in show and edit commands. Edit and show work in already synced projects. ` + config.RESET + `
` + config.PASTEL_CYAN + ` Info:
If you want to learn different ways to use a command, for example, just type envolve sync -h for sync.
In the description, you will find example information that you can give a path to a folder you want, not the current folder, with --path. ` + config.RESET + `
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
` + mainColor + `{{rpad .Name .NamePadding }}` + config.RESET + ` ` + config.PASTEL_BLUE + ` {{.Short}}{{end}}{{end}}{{end}} ` + config.RESET + `
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}
Use "{{.CommandPath}} [command] --help" for more information about a command.
`)

func Execute() {
envolvePath := logic.GetEnvolveHomePath()

Expand All @@ -34,4 +60,5 @@ func Execute() {
}

func init() {
rootCmd.SetHelpTemplate(customHelpTemplate)
}
7 changes: 5 additions & 2 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import (
var syncPath string

var syncCmd = &cobra.Command{
Use: "sync",
Short: "Backs up your current project's .env file",
Use: "sync",
Short: `For example, you have an application called x-service. And you have an .env file inside this application, in this case, run the envolve sync command in that project.
If you want, you can give the path and run it without being in that folder.With this, your .env file is copied to the .envolve folder and given as a symlink to the file you
are working on. This way, if you delete your project, your file will not be lost.
`,
Long: `Backs up your current project's .env file, restores the variables from a global .env file, and creates a symbolic link to the latest environment settings.
You can specify a path to sync files from using the --path flag if not it will use current path.`,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
5 changes: 3 additions & 2 deletions cmd/syncAll.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
var syncAllPath string

var syncAllCmd = &cobra.Command{
Use: "sync-all",
Short: "Synchronizes all environment variables across projects inside of the folder",
Use: "sync-all",
Short: `For example, you have a folder called projects. There is an .env file in each of your projects. If you do not want to sync them one by one, you can use sync-all. All your projects are automatically synced.
If you do not want to go to the Projects folder, you can give --path`,
Long: `Synchronizes all environment variables across projects.
Backs up .env files for all projects, restores variables from a global .env file,
and creates symbolic links to the latest environment settings. You can specify a path to sync files from using the --path flag if not it will use current path.`,
Expand Down
8 changes: 3 additions & 5 deletions internal/command/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func (command EditCommand) Execute(cmd *cobra.Command, args []string) {
if currentText == "" || len(envFiles) == 0 {
return nil
}
// Get all keys that start with the current text
for key := range envFiles[0].EnvVars { // Assuming envFiles is not empty

for key := range envFiles[0].EnvVars {
if strings.HasPrefix(key, currentText) {
entries = append(entries, key)
}
Expand Down Expand Up @@ -121,7 +121,7 @@ func (command EditCommand) Execute(cmd *cobra.Command, args []string) {

resultBox.SetText("[green]Successfully updated env files")
}).
AddButton("Update by Value", func() { // Add a new button for updating by value
AddButton("Update by Value", func() {
value := valueSearchBox.GetText()
newValue := valueBox.GetText()

Expand All @@ -144,8 +144,6 @@ func (command EditCommand) Execute(cmd *cobra.Command, args []string) {
app.Stop()
})

// Add empty TextView for spacing

form.SetTitle("Search").SetBorder(true)

flex := tview.NewFlex().
Expand Down
12 changes: 12 additions & 0 deletions internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ const (
const MAIN_COLOR = tcell.ColorLightGray
const FOLDER_COLOR = tcell.ColorDarkSlateBlue
const FILE_COLOR = tcell.ColorLightSalmon

// colors
const (
RESET = "\033[0m"
RED = "\033[31m"
PASTEL_RED = "\033[91m"
PESTEL_GREEN = "\033[92m"
PASTEL_YELLOW = "\033[93m"
PASTEL_BLUE = "\033[94m"
PASTEL_MAGENTA = "\033[95m"
PASTEL_CYAN = "\033[96m"
)
13 changes: 13 additions & 0 deletions internal/util/asci.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package util

import (
"fmt"

"github.com/gdamore/tcell/v2"
)

func TcellColorToAnsi(c tcell.Color) string {
// Assuming 24-bit color support, we convert the tcell.Color to ANSI escape code.
// This is a simplified approach assuming 24-bit color support.
return fmt.Sprintf("\033[38;2;%d;%d;%dm", (c>>16)&0xFF, (c>>8)&0xFF, c&0xFF)
}

0 comments on commit 10e6110

Please sign in to comment.