aboutsummaryrefslogtreecommitdiff
path: root/ext4/ext4.go
diff options
context:
space:
mode:
authorJoseph Richey <joerichey94@gmail.com>2017-10-16 10:50:53 -0700
committerJoseph Richey <joerichey94@gmail.com>2017-10-19 02:22:25 -0700
commitb5cc60b2b974645f0d09721c292cd243d049cbcf (patch)
treefbc44d87ba8dd83e2238ff8e217ea560f56b3091 /ext4/ext4.go
parentb4299090c3e503ba0c49a6086b1a46c218ca45f4 (diff)
Refactor almost complete
Diffstat (limited to 'ext4/ext4.go')
-rw-r--r--ext4/ext4.go44
1 files changed, 18 insertions, 26 deletions
diff --git a/ext4/ext4.go b/ext4/ext4.go
index 80d229d..dcf8204 100644
--- a/ext4/ext4.go
+++ b/ext4/ext4.go
@@ -25,58 +25,50 @@ import (
"github.com/google/fscrypt/cmd"
)
-// Arguments used with the ext4 enable/disable commands.
var (
- MountpointArg = &cmd.Argument{
+ mountpointArg = &cmd.Argument{
ArgName: "mountpoint",
Usage: "the path to an ext4 filesystem's mountpoint",
}
- DeviceArg = &cmd.Argument{
+ deviceArg = &cmd.Argument{
ArgName: "device",
Usage: "the path to a device containing an ext4 filesystem",
}
- Ext4Usage = fmt.Sprintf("(%s | %s) [options]", MountpointArg, DeviceArg)
+ ext4Usage = fmt.Sprintf("(%s | %s) [options]", mountpointArg, deviceArg)
)
-// Commands for running the ext4 enable/disable commands.
-var ()
+func main() { ext4Command.Run() }
-var Ext4Command = &cmd.Command{
- Title: "toggle ext4 filesystem encryption flag",
+var ext4Command = &cmd.Command{
+ Title: "manage ext4 encryption feature flag",
UsageLines: []string{
- fmt.Sprintf("(enable | disable) %s", Ext4Usage),
+ fmt.Sprintf("enable %s", ext4Usage),
+ fmt.Sprintf("disable %s", ext4Usage),
cmd.VersionUsage,
},
- SubCommands: []*cmd.Command{EnableCommand, DisableCommand, cmd.VersionCommand},
- Arguments: []*cmd.Argument{MountpointArg, DeviceArg},
+ SubCommands: []*cmd.Command{enableCommand, disableCommand, cmd.VersionCommand},
+ Arguments: []*cmd.Argument{mountpointArg, deviceArg},
Flags: []cmd.Flag{cmd.ForceFlag, cmd.VerboseFlag, cmd.HelpFlag},
- ManPage: &cmd.ManPage{
- Title: "fscrypt-ext4",
- Section: 8,
- },
+ ManPage: &cmd.ManPage{Name: "fscrypt-ext4", Section: 8},
}
-
-var EnableCommand = &cmd.Command{
+var enableCommand = &cmd.Command{
Name: "enable",
Title: "turn on encryption for an ext4 filesystem",
- UsageLines: []string{Ext4Usage},
+ UsageLines: []string{ext4Usage},
InheritArguments: true,
InheritFlags: true,
- Action: func(ctx *cmd.Context) error { return toggleState(ctx, true) },
+ Action: func(c *cmd.Context) error { return toggleState(c, true) },
}
-
-var DisableCommand = &cmd.Command{
+var disableCommand = &cmd.Command{
Name: "disable",
Title: "turn off encryption for an ext4 filesystem",
- UsageLines: []string{Ext4Usage},
+ UsageLines: []string{ext4Usage},
InheritArguments: true,
InheritFlags: true,
- Action: func(ctx *cmd.Context) error { return toggleState(ctx, false) },
+ Action: func(c *cmd.Context) error { return toggleState(c, false) },
}
-func main() { Ext4Command.Run() }
-
-func toggleState(ctx *cmd.Context, enable bool) error {
+func toggleState(c *cmd.Context, enable bool) error {
fmt.Fprintf(cmd.Output, "Toggle value = %v", enable)
return nil
}