Skip to content

Commit

Permalink
Simplify pin removal command
Browse files Browse the repository at this point in the history
* Add -d/--direct for direct pins instead of -r=false
* Remove explain as it does not belong here

License: MIT
Signed-off-by: Iaroslav Gridin <voker57@gmail.com>
  • Loading branch information
Voker57 committed Aug 23, 2018
1 parent 23a7aa0 commit 942bd58
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/commands/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,15 @@ var rmPinCmd = &cmds.Command{
Tagline: "Remove pinned objects from local storage.",
ShortDescription: `
Removes the pin from the given object allowing it to be garbage
collected if needed. (By default, recursively. Use -r=false for direct pins.)
collected if needed. By default, removes recursive pins.
`,
},

Arguments: []cmdkit.Argument{
cmdkit.StringArg("pin-path", true, true, "Pin paths").EnableStdin(),
},
Options: []cmdkit.Option{
cmdkit.BoolOption("recursive", "r", "Recursively unpin the object linked to by the specified object(s).").WithDefault(true),
cmdkit.BoolOption("explain", "e", "Check for other pinned objects which could cause specified object(s) to be indirectly pinned").WithDefault(false),
cmdkit.BoolOption("direct", "d", "Unpins a direct pin").WithDefault(false),
},
Type: PinOutput{},
Run: func(req cmds.Request, res cmds.Response) {
Expand All @@ -200,7 +199,8 @@ collected if needed. (By default, recursively. Use -r=false for direct pins.)
}

// set recursive flag
recursive, _, err := req.Option("recursive").Bool()
direct, _, err := req.Option("direct").Bool()
recursive := !direct
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
Expand Down

0 comments on commit 942bd58

Please sign in to comment.