Skip to content

Instantly share code, notes, and snippets.

@kyriediculous
Created May 10, 2019 13:09
Show Gist options
  • Save kyriediculous/38b34c9ff3cefdcde9f14f2e4b29845d to your computer and use it in GitHub Desktop.
Save kyriediculous/38b34c9ff3cefdcde9f14f2e4b29845d to your computer and use it in GitHub Desktop.
var readCmd = &cobra.Command{
Use: "read",
Short: "Find a Blog post by its ID",
Long: `Find a blog post by it's mongoDB Unique identifier.
If no blog post is found for the ID it will return a 'Not Found' error`,
RunE: func(cmd *cobra.Command, args []string) error {
id, err := cmd.Flags().GetString("id")
if err != nil {
return err
}
req := &blogpb.ReadBlogReq{
Id: id,
}
res, err := client.ReadBlog(context.Background(), req)
if err != nil {
return err
}
fmt.Println(res)
return nil
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment