aboutsummaryrefslogtreecommitdiff
path: root/check.go
diff options
context:
space:
mode:
Diffstat (limited to 'check.go')
-rw-r--r--check.go46
1 files changed, 30 insertions, 16 deletions
diff --git a/check.go b/check.go
index 78c1e66..2dfb786 100644
--- a/check.go
+++ b/check.go
@@ -1,29 +1,43 @@
package main
import (
+ "context"
"flag"
"fmt"
+
+ "github.com/google/subcommands"
)
// Usage: signify -C [-q] -p pubkey -x sigfile [file ...]
-func check(args []string) error {
- opts := flag.NewFlagSet("check", flag.ExitOnError)
- var (
- quiet = opts.Bool("q", false, "Quiet mode")
- pubFile = opts.String("p", "", "Public key file (required)")
- sigFile = opts.String("x", "", "Signature file (required)")
- )
- opts.Parse(args)
- if *pubFile == "" || *sigFile == "" {
- opts.Usage()
- return nil
+type checkCommand struct {
+ quiet bool
+ pubFile string
+ sigFile string
+}
+
+func (c *checkCommand) Name() string { return "check" }
+func (c *checkCommand) Synopsis() string { return "check signatures" }
+func (c *checkCommand) Usage() string {
+ return "check [-q] -p pubkey -x sigfile [file ...]\n"
+}
+
+func (c *checkCommand) SetFlags(f *flag.FlagSet) {
+ f.BoolVar(&c.quiet, "q", false, "quiet mode")
+ f.StringVar(&c.pubFile, "p", "", "public key file (required)")
+ f.StringVar(&c.sigFile, "x", "", "signature file (required)")
+}
+
+func (c *checkCommand) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
+ if c.pubFile == "" || c.sigFile == "" {
+ f.Usage()
+ return subcommands.ExitUsageError
}
- files := make([]string, opts.NArg())
- for i := 0; i < opts.NArg(); i++ {
- files[i] = opts.Arg(i)
+ files := make([]string, f.NArg())
+ for i := 0; i < f.NArg(); i++ {
+ files[i] = f.Arg(i)
}
fmt.Println(files)
- _, _, _ = quiet, pubFile, sigFile // TODO
- return nil
+ // TODO
+ return subcommands.ExitSuccess
}