mirror of
https://github.com/onyx-and-iris/gignore.git
synced 2025-04-16 02:23:53 +01:00
no need to pass client around
This commit is contained in:
parent
2fa49d0dd0
commit
6adea84322
@ -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)
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user