Skip to content

Commit

Permalink
add config handler
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Sep 16, 2018
1 parent bb95553 commit bd8a4ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cli/handler.go
Expand Up @@ -4,9 +4,11 @@ import (
"github.com/fatih/color"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli"
"github.com/mitchellh/go-homedir"
"os"
"strconv"
"strings"
"path/filepath"
)

func InstallHandler(c *cli.Context) {
Expand Down Expand Up @@ -81,3 +83,16 @@ func RepoHandler(c *cli.Context) {
color.Red("Command Not Supported!")
}
}

func ConfigHandler(c* cli.Context) {
configFilePath := filepath.Join(homedir.Dir(), "cvpm", "config.toml")
if _, err := os.Stat(configFilePath); os.IsNotExist(err) {
file, err := os.Create(configFilePath)
if err != nil {
color.Red("An error occured!")
}
defer file.Close()
}

}

7 changes: 7 additions & 0 deletions cli/main.go
Expand Up @@ -65,6 +65,13 @@ func main() {
return nil
},
},
{
Name: "config",
Action: func(c *cli.Context) error {
ConfigHandler(c)
return nil
},
},
}
err := cvpm.Run(os.Args)
if err != nil {
Expand Down

0 comments on commit bd8a4ff

Please sign in to comment.