corso/src/cli/options/options.go
Keepers 625cf744a6
adds the onError option to operations (#347)
* adds the onError option to operations

Adds the OnError option to operations.Options.  OnError tells
corso whether to continue despite concurrent processing
errors, or to exit processing on any error.  Also includes flag
support for setting the option.  Only adds the options, does
not assert error handling behavior in corso.
2022-07-19 14:20:12 -06:00

24 lines
613 B
Go

package options
import (
"github.com/alcionai/corso/internal/operations"
"github.com/spf13/cobra"
)
var (
fastFail bool
)
// AddFlags adds the operation option flags
func AddOperationFlags(parent *cobra.Command) {
fs := parent.Flags()
fs.BoolVar(&fastFail, "fast-fail", false, "stop processing immediately if any error occurs")
// TODO: reveal this flag when fail-fast support is implemented
cobra.CheckErr(fs.MarkHidden("fast-fail"))
}
// OperationOptions produces the operation options based on the user's flags.
func OperationOptions() operations.Options {
return operations.NewOptions(fastFail)
}