Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
rm username from dockma
Browse files Browse the repository at this point in the history
  • Loading branch information
martinnirtl committed Mar 5, 2020
1 parent c0ea3c6 commit cf0e0b9
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 29 deletions.
8 changes: 1 addition & 7 deletions internal/commands/configcmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/ttacon/chalk"
)

var configVars []string = []string{"hidesubcommandoutput", "username"}
var configVars []string = []string{"hidesubcommandoutput"}

func getSetCommand() *cobra.Command {
return &cobra.Command{
Expand All @@ -31,7 +31,6 @@ func runSetCommand(cmd *cobra.Command, args []string) {
if len(args) == 0 {
options := []string{
fmt.Sprintf("hidesubcommandoutput: %t", viper.GetBool("hidesubcommandoutput")),
fmt.Sprintf("username: %s", viper.GetString("username")),
}

selected = survey.MultiSelect("Select config items to change", options, nil)
Expand All @@ -56,10 +55,5 @@ func setConfigVar(varname string) {
hide := survey.Confirm("Hide output of external commands [true: show output only on error, false: always pipe output]", viper.GetBool("hidesubcommandoutput"))

viper.Set("hidesubcommandoutput", hide)

case "username":
username := survey.InputName("Enter new username", viper.GetString("username"))

viper.Set("username", username)
}
}
8 changes: 1 addition & 7 deletions internal/commands/hooks/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package hooks
import (
"fmt"
"os"
"os/user"
"strings"

"github.com/martinnirtl/dockma/internal/config"
"github.com/spf13/cobra"
Expand All @@ -20,11 +18,7 @@ func RequiresInit(cmd *cobra.Command, args []string) {
}

if init := viper.GetTime("init"); init.IsZero() {
if user, err := user.Current(); err == nil {
fmt.Printf("Come on, %s! Run %sdockma init%s first to initialize dockma.\n", strings.Title(user.Username), chalk.Cyan, chalk.ResetColor)
} else {
fmt.Printf("Please run %sdockma init%s first to initialize dockma.\n", chalk.Cyan, chalk.ResetColor)
}
fmt.Printf("Run %s first to initialize dockma.\n", chalk.Cyan.Color("dockma init"))

os.Exit(0)
}
Expand Down
9 changes: 0 additions & 9 deletions internal/commands/initcmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"os"
"os/user"
"path"
"time"

Expand Down Expand Up @@ -47,14 +46,6 @@ func initPreRunHook(cmd *cobra.Command, args []string) {
}

func runInitCommand(cmd *cobra.Command, args []string) {
username := "User"
if sysUser, err := user.Current(); err == nil {
username = sysUser.Username
}

username = survey.InputName("What is your name", username)

viper.Set("username", username)
viper.Set("init", time.Now())

home := config.GetHomeDir()
Expand Down
1 change: 0 additions & 1 deletion internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func init() {
viper.SetDefault("home", path.Join(userHome, ".dockma"))
}

viper.SetDefault("username", "User")
viper.SetDefault("hidesubcommandoutput", true)
viper.SetDefault("subcommandlogfile", "subcommand.log")
viper.SetDefault("dockmalogfile", "dockma.log")
Expand Down
5 changes: 0 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ func GetInitTime() time.Time {
return viper.GetTime("init")
}

// GetUsername returns the user's name.
func GetUsername() string {
return viper.GetString("username")
}

// GetHomeDir returns the full path to dockma home dir.
func GetHomeDir() string {
return viper.GetString("home")
Expand Down

0 comments on commit cf0e0b9

Please sign in to comment.