(ec *cli.ExecutionContext)
| 21 | ` |
| 22 | |
| 23 | func newMetadataExportCmd(ec *cli.ExecutionContext) *cobra.Command { |
| 24 | opts := &MetadataExportOptions{ |
| 25 | EC: ec, |
| 26 | } |
| 27 | |
| 28 | metadataExportCmd := &cobra.Command{ |
| 29 | Use: "export", |
| 30 | Short: "Export Hasura GraphQL Engine Metadata from the database", |
| 31 | Example: ` # Export metadata and save it in migrations/metadata.yaml file: |
| 32 | hasura metadata export |
| 33 | |
| 34 | # Use with admin secret: |
| 35 | hasura metadata export --admin-secret "<admin-secret>" |
| 36 | |
| 37 | # Export metadata from another instance specified by the flag: |
| 38 | hasura metadata export --endpoint "<endpoint>"`, |
| 39 | SilenceUsage: true, |
| 40 | RunE: func(cmd *cobra.Command, args []string) error { |
| 41 | op := genOpName(cmd, "RunE") |
| 42 | if len(opts.output) == 0 { |
| 43 | ec.Spin("Exporting metadata...") |
| 44 | } |
| 45 | err := opts.Run() |
| 46 | ec.Spinner.Stop() |
| 47 | if err != nil { |
| 48 | return errors.E(op, err) |
| 49 | } |
| 50 | if len(opts.output) == 0 { |
| 51 | ec.Logger.Info("Metadata exported") |
| 52 | } |
| 53 | return nil |
| 54 | }, |
| 55 | Long: longHelpMetadataExportCmd, |
| 56 | } |
| 57 | |
| 58 | f := metadataExportCmd.Flags() |
| 59 | f.StringVarP(&opts.output, "output", "o", "", `write metadata to standard output in given format for exported metadata (note: this won't modify project metadata) Allowed values: json, yaml")`) |
| 60 | |
| 61 | return metadataExportCmd |
| 62 | } |
| 63 | |
| 64 | type MetadataExportOptions struct { |
| 65 | EC *cli.ExecutionContext |
no test coverage detected