Skip to content

Commit

Permalink
This prints out the user creation information in a stylish manner
Browse files Browse the repository at this point in the history
  • Loading branch information
JAORMX committed Oct 4, 2023
1 parent 84f4f41 commit 0ba47bf
Show file tree
Hide file tree
Showing 11 changed files with 1,565 additions and 1,292 deletions.
61 changes: 52 additions & 9 deletions cmd/cli/app/auth/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"time"

"github.com/charmbracelet/bubbles/table"
"github.com/gorilla/securecookie"
"github.com/pkg/browser"
"github.com/spf13/cobra"
Expand All @@ -42,6 +42,7 @@ import (
"github.com/stacklok/mediator/internal/config"
mcrypto "github.com/stacklok/mediator/internal/crypto"
"github.com/stacklok/mediator/internal/util"
"github.com/stacklok/mediator/internal/util/cli"
"github.com/stacklok/mediator/internal/util/rand"
pb "github.com/stacklok/mediator/pkg/api/protobuf/go/mediator/v1"
)
Expand All @@ -54,7 +55,7 @@ func userRegistered(ctx context.Context, client pb.UserServiceClient) (bool, err
return false, nil
}
}
return false, fmt.Errorf("Error retrieving user %v", err)
return false, fmt.Errorf("error retrieving user %v", err)
}
return true, nil
}
Expand All @@ -67,7 +68,7 @@ var auth_loginCmd = &cobra.Command{
will be saved to $XDG_CONFIG_HOME/mediator/credentials.json`,
PreRun: func(cmd *cobra.Command, args []string) {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
fmt.Fprintf(os.Stderr, "Error binding flags: %s\n", err)
cli.Print(cmd.ErrOrStderr(), "Error binding flags: %s\n", err)
}
},
Run: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -137,15 +138,15 @@ will be saved to $XDG_CONFIG_HOME/mediator/credentials.json`,
loginUrl := fmt.Sprintf("http://localhost:%v/login", port)

// Redirect user to provider to log in
fmt.Printf("Your browser will now be opened to: %s\n", loginUrl)
fmt.Println("Please follow the instructions on the page to log in.")
cli.PrintCmd(cmd, "Your browser will now be opened to: %s", loginUrl)
cli.PrintCmd(cmd, "Please follow the instructions on the page to log in.")

// open user's browser to login page
if err := browser.OpenURL(loginUrl); err != nil {
fmt.Printf("You may login by pasting this URL into your browser: %s\n", loginUrl)
fmt.Printf("You may login by pasting this URL into your browser: %s", loginUrl)
}

fmt.Printf("Waiting for token\n")
cli.PrintCmd(cmd, "Waiting for token...")

// wait for the token to be received
token := <-tokenChan
Expand All @@ -166,9 +167,16 @@ will be saved to $XDG_CONFIG_HOME/mediator/credentials.json`,
util.ExitNicelyOnError(err, "Error fetching user")

if !registered {
fmt.Println("First login, registering user.")
_, err = client.CreateUser(ctx, &pb.CreateUserRequest{})
cli.PrintCmd(cmd, "First login, registering user.")
newUser, err := client.CreateUser(ctx, &pb.CreateUserRequest{})
util.ExitNicelyOnError(err, "Error registering user")

cli.PrintCmd(cmd, cli.CLIMarmot)
cli.PrintCmd(cmd, cli.WelcomeBannerText(
"You have been successfully registered. Welcome!"))
cli.PrintCmd(cmd, "\nHere are your details:")

renderNewUser(cmd, newUser)
}

fmt.Printf("You have been successfully logged in. Your access credentials saved to %s\n",
Expand All @@ -182,6 +190,41 @@ will be saved to $XDG_CONFIG_HOME/mediator/credentials.json`,
},
}

func renderNewUser(cmd *cobra.Command, newUser *pb.CreateUserResponse) {
columns := []table.Column{
{"Key", 30},

Check failure on line 195 in cmd/cli/app/auth/auth_login.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

composites: github.com/charmbracelet/bubbles/table.Column struct literal uses unkeyed fields (govet)
{"Value", 70},

Check failure on line 196 in cmd/cli/app/auth/auth_login.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

composites: github.com/charmbracelet/bubbles/table.Column struct literal uses unkeyed fields (govet)
}
rows := []table.Row{
{"Organization ID", newUser.OrganizationId},
{"Organization Name", newUser.OrganizatioName},
{"Project ID", newUser.ProjectId},
{"Project Name", newUser.ProjectName},
}

if newUser.Email != nil {
rows = append(rows, table.Row{"Email", *newUser.Email})
}

if newUser.FirstName != nil {
rows = append(rows, table.Row{"First Name", *newUser.FirstName})
}

if newUser.LastName != nil {
rows = append(rows, table.Row{"Last Name", *newUser.LastName})
}

t := table.New(
table.WithColumns(columns),
table.WithRows(rows),
table.WithFocused(false),
table.WithHeight(len(rows)),
table.WithStyles(cli.TableHiddenSelectStyles),
)

cli.PrintCmd(cmd, cli.TableRender(t))
}

func init() {
AuthCmd.AddCommand(auth_loginCmd)
}
4 changes: 3 additions & 1 deletion docs/docs/protodocs/proto.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ require (
github.com/alexdrl/zerowater v0.0.3
github.com/aws/aws-sdk-go-v2/config v1.18.43
github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.19
github.com/charmbracelet/bubbles v0.16.1
github.com/charmbracelet/glamour v0.6.0
github.com/charmbracelet/lipgloss v0.8.0
github.com/go-git/go-billy/v5 v5.5.0
github.com/go-git/go-git/v5 v5.9.0
github.com/go-playground/validator/v10 v10.15.5
Expand Down Expand Up @@ -59,6 +61,9 @@ require (
)

require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/bubbletea v0.24.1 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gorilla/schema v1.2.0 // indirect
Expand All @@ -67,6 +72,9 @@ require (
github.com/lestrrat-go/httprc v1.0.4 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muhlemmer/gu v0.3.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
)
Expand Down Expand Up @@ -119,7 +127,6 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.23.0 // indirect
github.com/aws/smithy-go v1.14.2 // indirect
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220228164355-396b2034c795 // indirect
github.com/aymanbagabas/go-osc52 v1.0.3 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
Expand Down Expand Up @@ -213,7 +220,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mozillazg/docker-credential-acr-helper v0.3.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.13.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nozzle/throttler v0.0.0-20180817012639-2ea982251481 // indirect
github.com/oklog/ulid v1.3.1 // indirect
Expand Down
21 changes: 19 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ=
github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220228164355-396b2034c795 h1:IWeCJzU+IYaO2rVEBlGPTBfe90cmGXFTLdhUFlzDGsY=
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220228164355-396b2034c795/go.mod h1:8vJsEZ4iRqG+Vx6pKhWK6U00qcj0KC37IsfszMkY6UE=
github.com/aymanbagabas/go-osc52 v1.0.3 h1:DTwqENW7X9arYimJrPeGZcV0ln14sGMt3pHZspWD+Mg=
github.com/aymanbagabas/go-osc52 v1.0.3/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
Expand All @@ -244,8 +245,14 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/charmbracelet/bubbles v0.16.1 h1:6uzpAAaT9ZqKssntbvZMlksWHruQLNxg49H5WdeuYSY=
github.com/charmbracelet/bubbles v0.16.1/go.mod h1:2QCp9LFlEsBQMvIYERr7Ww2H2bA7xen1idUDIzm/+Xc=
github.com/charmbracelet/bubbletea v0.24.1 h1:LpdYfnu+Qc6XtvMz6d/6rRY71yttHTP5HtrjMgWvixc=
github.com/charmbracelet/bubbletea v0.24.1/go.mod h1:rK3g/2+T8vOSEkNHvtq40umJpeVYDn6bLaqbgzhL/hg=
github.com/charmbracelet/glamour v0.6.0 h1:wi8fse3Y7nfcabbbDuwolqTqMQPMnVPeZhDM273bISc=
github.com/charmbracelet/glamour v0.6.0/go.mod h1:taqWV4swIMMbWALc0m7AfE9JkPSU8om2538k9ITBxOc=
github.com/charmbracelet/lipgloss v0.8.0 h1:IS00fk4XAHcf8uZKc3eHeMUTCxUH6NkaTrdyCQk84RU=
github.com/charmbracelet/lipgloss v0.8.0/go.mod h1:p4eYUZZJ/0oXTuCQKFF8mqyKCz0ja6y+7DniDDw5KKU=
github.com/chrismellard/docker-credential-acr-env v0.0.0-20220119192733-fe33c00cee21 h1:XlpL9EHrPOBJMLDDOf35/G4t5rGAFNNAZQ3cDcWavtc=
github.com/chrismellard/docker-credential-acr-env v0.0.0-20220119192733-fe33c00cee21/go.mod h1:Zlre/PVxuSI9y6/UV4NwGixQ48RHQDSPiUkofr6rbMU=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
Expand All @@ -263,6 +270,8 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+g
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE=
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ=
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k=
github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
Expand Down Expand Up @@ -734,6 +743,8 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
Expand Down Expand Up @@ -775,10 +786,15 @@ github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJ
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/mozillazg/docker-credential-acr-helper v0.3.0 h1:DVWFZ3/O8BP6Ue3iS/Olw+G07u1hCq1EOVCDZZjCIBI=
github.com/mozillazg/docker-credential-acr-helper v0.3.0/go.mod h1:cZlu3tof523ujmLuiNUb6JsjtHcNA70u1jitrrdnuyA=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.13.0 h1:wK20DRpJdDX8b7Ek2QfhvqhRQFZ237RGRO0RQ/Iqdy0=
github.com/muesli/termenv v0.13.0/go.mod h1:sP1+uffeLaEYpyOTb8pLCUctGcGLnoFjSn4YJK5e2bc=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/muhlemmer/gu v0.3.1 h1:7EAqmFrW7n3hETvuAdmFmn4hS8W+z3LgKtrnow+YzNM=
github.com/muhlemmer/gu v0.3.1/go.mod h1:YHtHR+gxM+bKEIIs7Hmi9sPT3ZDUvTN/i88wQpZkrdM=
github.com/muhlemmer/httpforwarded v0.1.0 h1:x4DLrzXdliq8mprgUMR0olDvHGkou5BJsK/vWUetyzY=
Expand Down Expand Up @@ -1293,6 +1309,7 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
15 changes: 12 additions & 3 deletions internal/controlplane/handlers_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,18 @@ func (s *Server) CreateUser(ctx context.Context,
return nil, status.Errorf(codes.Internal, "failed to commit transaction: %s", err)
}

return &pb.CreateUserResponse{Id: user.ID, OrganizationId: user.OrganizationID.String(), Email: &user.Email.String,
IdentitySubject: user.IdentitySubject, FirstName: &user.FirstName.String, LastName: &user.LastName.String,
CreatedAt: timestamppb.New(user.CreatedAt), UpdatedAt: timestamppb.New(user.UpdatedAt)}, nil
return &pb.CreateUserResponse{
Id: user.ID,
OrganizationId: user.OrganizationID.String(),
OrganizatioName: organization.Name,
ProjectId: userProject.String(),
ProjectName: orgProject.Name,
Email: &user.Email.String,
IdentitySubject: user.IdentitySubject,
FirstName: &user.FirstName.String,
LastName: &user.LastName.String,
CreatedAt: timestamppb.New(user.CreatedAt),
}, nil
}

type deleteUserValidation struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/controlplane/handlers_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ func TestCreateUser_gRPC(t *testing.T) {
assert.NotNil(t, res)
assert.Equal(t, int32(1), res.Id)
assert.Equal(t, orgID.String(), res.OrganizationId)
assert.Equal(t, projectID.String(), res.ProjectId)
assert.NotNil(t, res.CreatedAt)
assert.NotNil(t, res.UpdatedAt)
},
expectedStatusCode: codes.OK,
},
Expand Down
75 changes: 75 additions & 0 deletions internal/util/cli/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// Copyright 2023 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// NOTE: This file is for stubbing out client code for proof of concept
// purposes. It will / should be removed in the future.
// Until then, it is not covered by unit tests and should not be used
// It does make a good example of how to use the generated client code
// for others to use as a reference.

// Package cli contains utility for the cli
package cli

import (
"fmt"
"io"

"github.com/spf13/cobra"
)

// CLIMarmot is an ascii-art marmot
var CLIMarmot = `
.
.. ...
... ...
. ......
.. ....
... ...
..
.. ... ..
...-+*==--+- ...
+-.:==-::::+: ...
::-==-::::-+ ...
.=++====:::- ...
:====-::::::. ...
:====-::::::::. .
::----::::::::::: .
:::::::---:::::::-:
.:::-::::=-::------: .
=---+:::-::-===+== ..
.====-::::====-=++.
:=+++:::=++-:----- .
.==-==-::..--::--:::: ..
:------:::.:::---:::: ..
.-------:::::::-----. ..
---===----::::-=--- ..
.-=+=:-::::::=*+=:.. .
.==-::......:.:.....::::::..
.................:::::...........::..
...::......::::::..........::.......:::::::..
.....:::...:::::.........................::::::-::.
.::::......::............................:::.:..:::::::.
.....::...................................::::::.::::::.::::.
...........................................:.::.::.:::::::::::::.
............................................:::....::::::::::::::::.
`

func PrintCmd(cmd *cobra.Command, msg string, args ...interface{}) {

Check failure on line 69 in internal/util/cli/cli.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

exported: exported function PrintCmd should have comment or be unexported (revive)
Print(cmd.OutOrStdout(), msg, args...)
}

func Print(out io.Writer, msg string, args ...interface{}) {

Check failure on line 73 in internal/util/cli/cli.go

View workflow job for this annotation

GitHub Actions / golangci-lint / Go Lint

exported: exported function Print should have comment or be unexported (revive)
fmt.Fprintf(out, msg+"\n", args...)
}
Loading

0 comments on commit 0ba47bf

Please sign in to comment.