Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add name flag for describe connection #31

Merged
merged 2 commits into from
Aug 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions cmd/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package cmd

import (
"context"
"errors"
"fmt"
"strconv"
"github.com/meroxa/meroxa-go"
"time"

"github.com/spf13/cobra"
Expand All @@ -40,6 +41,9 @@ var describeResourceCmd = &cobra.Command{
name := args[0]

c, err := client()
if err != nil {
fmt.Println("Error: ", err)
}
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
Expand All @@ -54,25 +58,32 @@ var describeResourceCmd = &cobra.Command{
}

var describeConnectionCmd = &cobra.Command{
Use: "connection",
Use: "connection [name]",
Short: "describe connection",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("requires a connection name")
}
return nil
},
Run: func(cmd *cobra.Command, args []string) {
var (
err error
conn *meroxa.Connector
)
name := args[0]
c, err := client()
intID, err := strconv.Atoi(args[0])
if err != nil {
fmt.Println("Error: ", err)
}

ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

res, err := c.GetConnection(ctx, intID)
conn, err = c.GetConnectionByName(ctx, name)
if err != nil {
fmt.Println("Error: ", err)
return
}

prettyPrint("connection", res)
prettyPrint("connection", conn)
},
}

Expand Down