From bae71b983ec7415f9a0361521247f0adc6e1be0e Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 19 Jun 2025 04:39:43 +0100 Subject: [PATCH] bump to 1.0.0 --- context.go | 8 ++++---- main.go | 5 +---- new.go | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/context.go b/context.go index 7d432ee..d6a2a55 100644 --- a/context.go +++ b/context.go @@ -10,13 +10,13 @@ type contextKey string var clientKey = contextKey("client") -// withClient returns a new context with the GitHub client set. -func withClient(ctx context.Context, client *github.Client) context.Context { +// WithClient returns a new context with the GitHub client set. +func WithClient(ctx context.Context, client *github.Client) context.Context { return context.WithValue(ctx, clientKey, client) } -// clientFromContext retrieves the GitHub client from the context. -func clientFromContext(ctx context.Context) (*github.Client, bool) { +// ClientFromContext retrieves the GitHub client from the context. +func ClientFromContext(ctx context.Context) (*github.Client, bool) { client, ok := ctx.Value(clientKey).(*github.Client) return client, ok } diff --git a/main.go b/main.go index 60d1762..68a64a7 100644 --- a/main.go +++ b/main.go @@ -30,11 +30,8 @@ You may also list available templates and generate .gitignore files based on tho } else { client = github.NewClient(nil).WithAuthToken(viper.GetString("token")) } - ctx := withClient(cmd.Context(), client) - cmd.SetContext(ctx) + cmd.SetContext(WithClient(cmd.Context(), client)) }, - //RunE: func(cmd *cobra.Command, _ []string) error { - //}, } // init initialises the root command and its flags. diff --git a/new.go b/new.go index 7e98ed5..4d24302 100644 --- a/new.go +++ b/new.go @@ -13,7 +13,7 @@ import ( "github.com/spf13/viper" ) -const gitignoreFileName = ".gitignore" +const gitignoreFileName string = ".gitignore" // newCmd represents the new command. var newCmd = &cobra.Command{ @@ -47,7 +47,7 @@ func runNewCommand(cmd *cobra.Command, _ []string) error { return errors.New("height must be a positive integer") } - client, ok := clientFromContext(cmd.Context()) + client, ok := ClientFromContext(cmd.Context()) if !ok { return errors.New("failed to get GitHub client from context") }