added feedback for metadata commands (close #1411) (#1929)

This commit is contained in:
Aravind Shankar 2019-04-03 11:22:03 +05:30 committed by Shahidh K Muhammed
parent d53c70cbcd
commit 1e20026ea2
4 changed files with 34 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package commands
import (
"github.com/hasura/graphql-engine/cli"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
@ -24,7 +25,14 @@ func newMetadataApplyCmd(ec *cli.ExecutionContext) *cobra.Command {
return ec.Validate()
},
RunE: func(cmd *cobra.Command, args []string) error {
return opts.run()
opts.EC.Spin("Applying metadata...")
err := opts.run()
opts.EC.Spinner.Stop()
if err != nil {
return errors.Wrap(err, "failed to apply metadata")
}
opts.EC.Logger.Info("Metadata applied")
return nil
},
}

View File

@ -29,7 +29,14 @@ func newMetadataClearCmd(ec *cli.ExecutionContext) *cobra.Command {
if cmd.CalledAs() == "reset" {
opts.EC.Logger.Warn("metadata reset command is deprecated, use metadata clear instead")
}
return opts.run()
opts.EC.Spin("Clearing metadata...")
err := opts.run()
opts.EC.Spinner.Stop()
if err != nil {
return errors.Wrap(err, "failed to clear metadata")
}
opts.EC.Logger.Info("Metadata cleared")
return nil
},
}

View File

@ -2,6 +2,7 @@ package commands
import (
"github.com/hasura/graphql-engine/cli"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
@ -30,7 +31,14 @@ func newMetadataExportCmd(ec *cli.ExecutionContext) *cobra.Command {
return ec.Validate()
},
RunE: func(cmd *cobra.Command, args []string) error {
return opts.run()
opts.EC.Spin("Exporting metadata...")
err := opts.run()
opts.EC.Spinner.Stop()
if err != nil {
return errors.Wrap(err, "failed to export metadata")
}
opts.EC.Logger.Info("Metadata exported")
return nil
},
Long: longHelpMetadataExportCmd,
}

View File

@ -25,7 +25,14 @@ func newMetadataReloadCmd(ec *cli.ExecutionContext) *cobra.Command {
return ec.Validate()
},
RunE: func(cmd *cobra.Command, args []string) error {
return opts.run()
opts.EC.Spin("Reloading metadata...")
err := opts.run()
opts.EC.Spinner.Stop()
if err != nil {
return errors.Wrap(err, "failed to reload metadata")
}
opts.EC.Logger.Info("Metadata reloaded")
return nil
},
}