github.com/landoop/schema-registry@v0.0.0-20190327143759-50a5701c1891/schema-registry-cli/cmd/add.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "log" 6 7 "github.com/spf13/cobra" 8 ) 9 10 var addCmd = &cobra.Command{ 11 Use: "add <subject>", 12 Short: "registers the schema provided through stdin", 13 Long: ``, 14 SilenceUsage: true, 15 RunE: func(cmd *cobra.Command, args []string) error { 16 if len(args) != 1 { 17 return fmt.Errorf("expected 1 argument") 18 } 19 id, err := assertClient().RegisterNewSchema(args[0], stdinToString()) 20 if err != nil { 21 return err 22 } 23 log.Printf("registered schema with id %d\n", id) 24 return nil 25 }, 26 } 27 28 func init() { 29 RootCmd.AddCommand(addCmd) 30 }