mirror of
https://github.com/onyx-and-iris/gignore.git
synced 2025-03-31 10:51:19 +01:00
Compare commits
6 Commits
f0b64e3a75
...
eaf091dc1a
Author | SHA1 | Date | |
---|---|---|---|
eaf091dc1a | |||
99871a9040 | |||
1ca4304806 | |||
59521e1cd0 | |||
fcb23a3c01 | |||
c2b7dfcb18 |
15
README.md
15
README.md
@ -7,6 +7,13 @@
|
||||
|
||||
## Install
|
||||
|
||||
With Go tools:
|
||||
|
||||
```bash
|
||||
go generate ./...
|
||||
go install ./cmd/gignore
|
||||
```
|
||||
|
||||
With [Task][task]:
|
||||
|
||||
```bash
|
||||
@ -37,7 +44,7 @@ Example:
|
||||
|
||||
## Custom Templates
|
||||
|
||||
It's possible to add your own custom templates, simply create a directory in `internal/registry/templates`. You'll need to rebuild the project before you can load the new templates.
|
||||
It's possible to add your own custom templates, simply create a directory in `internal/registry/templates`. You'll need to [reinstall](https://github.com/onyx-and-iris/gignore?tab=readme-ov-file#install) the project before you can load the new templates.
|
||||
|
||||
Then pass the dir name as a flag, for example:
|
||||
|
||||
@ -53,11 +60,11 @@ If a template is requested but not found in the custom directory then the gitign
|
||||
|
||||
[gitignore.io][gitignoreio] For providing such a useful .gitignore service
|
||||
|
||||
[mh-cbon][mh-cbon] For writing the [gigo][gigo] client library for gitignore.io
|
||||
[cuonglm][cuonglm] For writing the [gogi][gogi] client library for gitignore.io
|
||||
|
||||
|
||||
[task]: https://taskfile.dev/
|
||||
[gitignoreio]: https://www.toptal.com/developers/gitignore
|
||||
[mh-cbon]: https://github.com/mh-cbon
|
||||
[gigo]: https://github.com/mh-cbon/gigo
|
||||
[cuonglm]: https://github.com/cuonglm
|
||||
[gogi]: https://github.com/cuonglm/gogi
|
||||
[ignore]: https://github.com/neptship/ignore
|
||||
|
@ -23,13 +23,6 @@ tasks:
|
||||
- task: build-windows
|
||||
- task: build-linux
|
||||
|
||||
release:
|
||||
desc: Generate the gitignore.io templates and then build the gignore project for Windows and Linux
|
||||
deps: [generate]
|
||||
cmds:
|
||||
- task: build-windows
|
||||
- task: build-linux
|
||||
|
||||
vet:
|
||||
desc: Vet the code
|
||||
deps: [fmt]
|
||||
@ -44,7 +37,7 @@ tasks:
|
||||
generate:
|
||||
desc: Generate the gitignore.io templates
|
||||
cmds:
|
||||
- go generate .
|
||||
- go generate ./...
|
||||
|
||||
build-windows:
|
||||
desc: Build the gignore project for Windows
|
||||
|
@ -20,10 +20,25 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
errChan := make(chan error)
|
||||
doneChan := make(chan struct{})
|
||||
|
||||
for _, template := range templates {
|
||||
err := createTemplate(template)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to create template %s: %v\n", template.Name, err)
|
||||
go func() {
|
||||
err := createTemplate(template)
|
||||
if err != nil {
|
||||
errChan <- fmt.Errorf("Failed to create template %s: %v", template.Name, err)
|
||||
return
|
||||
}
|
||||
doneChan <- struct{}{}
|
||||
}()
|
||||
}
|
||||
|
||||
for range templates {
|
||||
select {
|
||||
case err := <-errChan:
|
||||
log.Error(err)
|
||||
case <-doneChan:
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
//go:generate go run cmd/gen/gen.go
|
||||
//go:generate go run cmd/gen/main.go
|
||||
|
||||
// Client is a client for managing .gitignore templates.
|
||||
type Client struct {
|
||||
@ -32,7 +32,7 @@ func New(options ...Option) *Client {
|
||||
|
||||
// List returns a list of available .gitignore templates.
|
||||
func (c *Client) List() ([]string, error) {
|
||||
return c.registry.ListTemplates()
|
||||
return c.registry.List()
|
||||
}
|
||||
|
||||
// Create generates a .gitignore file from the specified template.
|
||||
@ -60,7 +60,7 @@ func (c *Client) Create(template string) error {
|
||||
log.Infof("template '%s' found in default gitignoreio registry", template)
|
||||
}
|
||||
|
||||
content, err := c.registry.GetTemplate(template)
|
||||
content, err := c.registry.Get(template)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ func (t *TemplateRegistry) Contains(name string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetTemplate retrieves the content of the gitignore template with the given name.
|
||||
func (t *TemplateRegistry) GetTemplate(name string) ([]byte, error) {
|
||||
// Get retrieves the content of the gitignore template with the given name.
|
||||
func (t *TemplateRegistry) Get(name string) ([]byte, error) {
|
||||
data, err := fs.ReadFile(t.templates, t.filePath(name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -50,8 +50,8 @@ func (t *TemplateRegistry) GetTemplate(name string) ([]byte, error) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// ListTemplates lists all the gitignore templates in the registry.
|
||||
func (t *TemplateRegistry) ListTemplates() ([]string, error) {
|
||||
// List lists all the gitignore templates in the registry.
|
||||
func (t *TemplateRegistry) List() ([]string, error) {
|
||||
var paths []string
|
||||
|
||||
err := fs.WalkDir(
|
||||
|
Loading…
x
Reference in New Issue
Block a user