Skip to content

Commit

Permalink
added del command for deleting properties
Browse files Browse the repository at this point in the history
* using forked properties library until pr is merged
  • Loading branch information
oconnormi committed Jan 11, 2017
1 parent 6706eea commit 234ccc5
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 7 deletions.
27 changes: 26 additions & 1 deletion props.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/urfave/cli"
"github.com/magiconair/properties"
"github.com/oconnormi/properties"

"github.com/oconnormi/props/version"
)
Expand Down Expand Up @@ -54,9 +54,34 @@ func main() {
if e != nil {
return cli.NewExitError("could not write file", 3)
}
fo.Close()
return nil
},
},
{
Name: "del",
Aliases: []string{"d"},
Usage: "deletes a property",
Action: func (c *cli.Context) error {
key := c.Args().Get(0)
path := c.Args().Get(1)

p := properties.MustLoadFile(path, properties.UTF8)

p.Delete(key)

fo, err := os.Create(path)
if err != nil {
return cli.NewExitError("could not create file", 2)
}
_, e := p.WriteComment(fo, "#", properties.UTF8)
if e != nil {
return cli.NewExitError("could not write file", 3)
}
fo.Close()
return nil
},
},
}
app.Run(os.Args)
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"ignore": "test",
"package": [
{
"checksumSHA1": "506eXGmFfB7mgzbMcsdT/UAXJgI=",
"path": "github.com/magiconair/properties",
"revision": "9c47895dc1ce54302908ab8a43385d1f5df2c11c",
"revisionTime": "2016-11-28T00:34:34Z"
"checksumSHA1": "LH4X/kevmgb7CQA53NcqKBzaA00=",
"path": "github.com/oconnormi/properties",
"revision": "688c939da3937df07f3a5e3ffb6e11690d370407",
"revisionTime": "2017-01-11T00:37:39Z",
"version": "fix_delete",
"versionExact": "fix_delete"
},
{
"checksumSHA1": "LMu1NsthSqcXfKu0m6YGPAmwBcY=",
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
var GitCommit string

// The main version number that is being run at the moment.
const Version = "0.1.1"
const Version = "0.2.0"

// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
Expand Down

0 comments on commit 234ccc5

Please sign in to comment.