no need to pass client around

This commit is contained in:
onyx-and-iris 2025-04-13 14:35:43 +01:00
parent 2fa49d0dd0
commit 6adea84322
2 changed files with 4 additions and 6 deletions

View File

@ -5,7 +5,6 @@ package main
import ( import (
"fmt" "fmt"
"github.com/onyx-and-iris/gignore"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -25,7 +24,7 @@ Example:
} }
for _, arg := range args { for _, arg := range args {
createTemplate(client, arg) createTemplate(arg)
} }
}, },
} }
@ -36,7 +35,7 @@ func init() {
} }
// createTemplate creates a new .gitignore file using the specified template. // createTemplate creates a new .gitignore file using the specified template.
func createTemplate(client *gignore.Client, template string) { func createTemplate(template string) {
err := client.Create(template) err := client.Create(template)
cobra.CheckErr(err) cobra.CheckErr(err)
fmt.Printf("√ created %s .gitignore file\n", template) fmt.Printf("√ created %s .gitignore file\n", template)

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/onyx-and-iris/gignore"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -20,7 +19,7 @@ You can use this command to quickly find all available .gitignore templates.
Example: Example:
gignore --root=<path> list`, gignore --root=<path> list`,
Run: func(_ *cobra.Command, _ []string) { Run: func(_ *cobra.Command, _ []string) {
if err := listTemplates(client); err != nil { if err := listTemplates(); err != nil {
cobra.CheckErr(err) cobra.CheckErr(err)
} }
}, },
@ -33,7 +32,7 @@ func init() {
// listTemplates retrieves and prints all .gitignore templates available from the gignore client. // listTemplates retrieves and prints all .gitignore templates available from the gignore client.
// It takes a gignore.Client as a parameter and returns an error if the operation fails. // It takes a gignore.Client as a parameter and returns an error if the operation fails.
func listTemplates(client *gignore.Client) error { func listTemplates() error {
templates, err := client.List() templates, err := client.List()
if err != nil { if err != nil {
return err return err