graphql-engine/cli/commands/metadata_inconsistency_status.go
Aravind Shankar bb63d7e60e
cli: allow managing actions (#3859)
Co-authored-by: Rishichandra Wawhal <rishichandra.wawhal@gmail.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
Co-authored-by: Aravind <aravindkp@outlook.in>
Co-authored-by: Anon Ray <ecthiender@users.noreply.github.com>
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
2020-02-24 21:44:46 +05:30

36 lines
907 B
Go

package commands
import (
"github.com/hasura/graphql-engine/cli"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func newMetadataInconsistencyStatusCmd(ec *cli.ExecutionContext) *cobra.Command {
opts := &metadataInconsistencyListOptions{
EC: ec,
}
metadataInconsistencyStatusCmd := &cobra.Command{
Use: "status",
Short: "Check if the metadata is inconsistent or not",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
opts.EC.Spin("reading metadata status...")
err := opts.read()
opts.EC.Spinner.Stop()
if err != nil {
return errors.Wrap(err, "failed to read metadata status")
}
if opts.isConsistent {
opts.EC.Logger.Println("metadata is consistent")
} else {
return errors.New("metadata is inconsistent, use list command to see the objects")
}
return nil
},
}
return metadataInconsistencyStatusCmd
}