Skip to content

Instantly share code, notes, and snippets.

View kyriediculous's full-sized avatar

Nico Vergauwen kyriediculous

View GitHub Profile
{
"contractName": "Wallet",
"abi": [
{
"inputs": [
{
"name": "_master",
"type": "address"
}
],
'use strict'
const TestHarness = require('../src/index')
let th = new TestHarness()
th.run({
name: 'testnet', // specify unique config name here
discordUserId: null, // id of Discord user to send alert from Prometheus to (use `Copy ID` on profile to get)
// should be string
// listCmd represents the read command
var listCmd = &cobra.Command{
Use: "list",
Short: "List all blog posts",
RunE: func(cmd *cobra.Command, args []string) error {
// Create the request (this can be inline below too)
req := &blogpb.ListBlogsReq{}
// Call ListBlogs that returns a stream
stream, err := client.ListBlogs(context.Background(), req)
// Check for errors
var deleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete a Blog post by its ID",
Long: `Delete 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
var updateCmd = &cobra.Command{
Use: "update",
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 {
// Get the flags from CLI
id, err := cmd.Flags().GetString("id")
author, err := cmd.Flags().GetString("author")
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
func init() {
readCmd.Flags().StringP("id", "i", "", "The id of the blog")
readCmd.MarkFlagRequired("id")
rootCmd.AddCommand(readCmd)
}
// createCmd represents the create command
var createCmd = &cobra.Command{
Use: "create",
Short: "Create a new blog post",
Long: `Create a new blogpost on the server through gRPC.
A blog post requires an AuthorId, Title and Content.`,
RunE: func(cmd *cobra.Command, args []string) error {
// Get the data from our flags
author, err := cmd.Flags().GetString("author")
func init() {
createCmd.Flags().StringP("author", "a", "", "Add an author")
createCmd.Flags().StringP("title", "t", "", "A title for the blog")
createCmd.Flags().StringP("content", "c", "", "The content for the blog")
createCmd.MarkFlagRequired("author")
createCmd.MarkFlagRequired("title")
createCmd.MarkFlagRequired("content")
rootCmd.AddCommand(createCmd)
}
var cfgFile string
// Client and context global vars for the cmd package
// So they can be used by our subcommands
var client blogpb.BlogServiceClient
var requestCtx context.Context
var requestOpts grpc.DialOption
func init() {
// initConfig reads in config file and ENV variables