Skip to content

Commit

Permalink
Merge branch 'hotfix/fix_set_from_file'
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleiade committed Apr 17, 2014
2 parents 260ed84 + a562a98 commit c6c136e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions trousseau/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,23 +296,25 @@ func GetAction(c *cli.Context) {
log.Fatal(err)
}

fmt.Printf("%s\n", value)
fmt.Printf("%s", value)
}

func SetAction(c *cli.Context) {
var key string
var value interface{}
var value string
var err error

// If the --file flag is provided
if c.String("file") != "" && hasExpectedArgs(c.Args(), 1) {
// And the file actually exists on file system
if pathExists(c.String("file")) {
// Then load it's content
value, err = ioutil.ReadFile(c.String("file"))
fileContent, err := ioutil.ReadFile(c.String("file"))
if err != nil {
log.Fatal(err)
}

value = string(fileContent)
} else {
log.Fatalf("Cannot open %s because it doesn't exist", c.String("file"))
}
Expand Down Expand Up @@ -344,7 +346,7 @@ func SetAction(c *cli.Context) {
log.Fatal(err)
}

fmt.Printf("%s:%s\n", key, value)
fmt.Printf("%s:%s", key, value)
}

func DelAction(c *cli.Context) {
Expand Down Expand Up @@ -372,7 +374,7 @@ func DelAction(c *cli.Context) {
log.Fatal(err)
}

fmt.Printf("deleted: %s\n", c.Args()[0])
fmt.Printf("deleted: %s", c.Args()[0])
}

func KeysAction(c *cli.Context) {
Expand Down

0 comments on commit c6c136e

Please sign in to comment.