// return subcommands for our particular area of algorithms func SubCommands() []gcli.Command { out := make([]gcli.Command, 1) cmd := verify.Command{} verify := gcli.Command{ Name: verify.Name, ShortName: "", Usage: verifyDescription, Action: func(c *gcli.Context) { cli.RunAction(&cmd, c) }, Before: func(c *gcli.Context) error { return cli.CheckCommonFlagsAndInit(&cmd, c) }, } out[0] = verify return out }
func startSealedCopy(cmd *seal.Command, c *gcli.Context) { // Yes, currently the post-verification is only implemented in the CLI ... // Testing needs to do similar things to set it up ... if cmd.Verify { // Setup a aggregation result handler which tracks produced indices var indices []string cmdDone := make(chan bool) handler := cli.MakeLogHandler(cmd.LogLevel()) aggHandler := api.IndexTrackingResultHandlerAdapter(&indices, handler) // and run ourselves err := api.StartEngine(cmd, aggHandler) // Make sure we don't keep logging while verification is going with its own handler close(cmdDone) if err == nil && len(indices) == 0 { panic("Unexpectedly I didn't see a single seal index without error") } else if len(indices) > 0 { // no matter whether we have an error, try to verify what's there select { case <-cmd.Done: // this does nothing, most importantly, it doesn't run verify, as we don't run it // after cancellation. It's arguable whether we migth want to do that anyway // as the index is valid ! default: { // prepare and run a verify command verifycmd, err := verify.NewCommand(indices, c.GlobalInt(cli.StreamsPerInputDeviceFlagName)) if err == nil { err = api.StartEngine(verifycmd, handler) } } } } // Finally, exit with appropriate error code if err != nil { os.Exit(1) } } else { // copy without verify cli.RunAction(cmd, c) } }
// return subcommands for our particular area of algorithms func SubCommands() []gcli.Command { cmdseal := seal.Command{Mode: seal.ModeSeal} cmdcopy := seal.Command{Mode: seal.ModeCopy} fmt := gcli.StringFlag{ Name: formatFlag, Value: codec.GobName, Usage: formatDescription, } return []gcli.Command{ gcli.Command{ Name: seal.ModeSeal, ShortName: "", Usage: sealDescription, Action: func(c *gcli.Context) { cli.RunAction(&cmdseal, c) }, Before: func(c *gcli.Context) error { return checkSeal(&cmdseal, c) }, Flags: []gcli.Flag{fmt}, }, gcli.Command{ Name: seal.ModeCopy, ShortName: "", Usage: sealedCopyDescription, Action: func(c *gcli.Context) { startSealedCopy(&cmdcopy, c) }, Before: func(c *gcli.Context) error { return checkSealedCopy(&cmdcopy, c) }, Flags: []gcli.Flag{ gcli.BoolFlag{ Name: verifyAfterCopy, Usage: "Run `godi verify` on all produced seals when copy is finished"}, gcli.IntFlag{ Name: streamsPerOutputDevice + ", spod", Value: 1, Usage: "Amount of parallel streams per output device"}, fmt, }, }, } }