mirror of
https://github.com/onyx-and-iris/ignr.git
synced 2026-04-18 07:13:33 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f51302a945 | |||
| 11fe797f3f | |||
| 5b389aa9dc | |||
| bb535f296d | |||
| 5eccfc939c | |||
| 00638a6bf4 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
# Generated by ignr-cli: github.com/onyx-and-iris/ignr-cli
|
# Generated by ignr: github.com/onyx-and-iris/ignr
|
||||||
|
|
||||||
## Go ##
|
## Go ##
|
||||||
# If you prefer the allow list template instead of the deny list, see community template:
|
# If you prefer the allow list template instead of the deny list, see community template:
|
||||||
@@ -36,4 +36,4 @@ go.work.sum
|
|||||||
# .idea/
|
# .idea/
|
||||||
# .vscode/
|
# .vscode/
|
||||||
|
|
||||||
# End of ignr-cli
|
# End of ignr
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
# ignr-cli
|
# ignr
|
||||||
|
|
||||||
Simple no-frills .gitignore generator backed by the Github API.
|
Simple no-frills .gitignore generator backed by the Github API.
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ Simple no-frills .gitignore generator backed by the Github API.
|
|||||||
## Install
|
## Install
|
||||||
|
|
||||||
```console
|
```console
|
||||||
go install github.com/onyx-and-iris/ignr-cli@latest
|
go install github.com/onyx-and-iris/ignr@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
@@ -41,7 +41,7 @@ export IGNR_FILTER=startswith
|
|||||||
Trigger the selection prompt.
|
Trigger the selection prompt.
|
||||||
|
|
||||||
```console
|
```console
|
||||||
ignr-cli new
|
ignr new
|
||||||
```
|
```
|
||||||
|
|
||||||
The prompt filter can be activated by pressing `/`:
|
The prompt filter can be activated by pressing `/`:
|
||||||
@@ -50,4 +50,5 @@ The prompt filter can be activated by pressing `/`:
|
|||||||
|
|
||||||
## Special Thanks
|
## Special Thanks
|
||||||
|
|
||||||
- [Charm](https://github.com/charmbracelet) for their awesome CLI packages.
|
- [spf13](https://github.com/spf13) for the [cobra](https://github.com/spf13/cobra) and [viper](https://github.com/spf13/viper) packages.
|
||||||
|
- [Manifold](https://github.com/manifoldco) for the [promptui](https://github.com/manifoldco/promptui) package.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
PROGRAM: ignr-cli
|
PROGRAM: ignr
|
||||||
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
|
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
|
||||||
BIN_DIR: bin
|
BIN_DIR: bin
|
||||||
VERSION:
|
VERSION:
|
||||||
@@ -12,12 +12,12 @@ vars:
|
|||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
default:
|
default:
|
||||||
desc: Build the ignr-cli project
|
desc: Build the ignr project
|
||||||
cmds:
|
cmds:
|
||||||
- task: build
|
- task: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
desc: Build the ignr-cli project
|
desc: Build the ignr project
|
||||||
deps: [vet]
|
deps: [vet]
|
||||||
cmds:
|
cmds:
|
||||||
- task: build-windows
|
- task: build-windows
|
||||||
@@ -35,13 +35,13 @@ tasks:
|
|||||||
- go fmt ./...
|
- go fmt ./...
|
||||||
|
|
||||||
build-windows:
|
build-windows:
|
||||||
desc: Build the ignr-cli project for Windows
|
desc: Build the ignr project for Windows
|
||||||
cmds:
|
cmds:
|
||||||
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}"
|
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}"
|
||||||
internal: true
|
internal: true
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
desc: Build the ignr-cli project for Linux
|
desc: Build the ignr project for Linux
|
||||||
cmds:
|
cmds:
|
||||||
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}"
|
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}"
|
||||||
internal: true
|
internal: true
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module github.com/onyx-and-iris/ignr-cli
|
module github.com/onyx-and-iris/ignr
|
||||||
|
|
||||||
go 1.24.3
|
go 1.24.3
|
||||||
|
|
||||||
|
|||||||
6
main.go
6
main.go
@@ -18,9 +18,9 @@ var version string // Version of the CLI, set during build time
|
|||||||
|
|
||||||
// rootCmd represents the base command when called without any subcommands.
|
// rootCmd represents the base command when called without any subcommands.
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "ignr-cli",
|
Use: "ignr",
|
||||||
Short: "A command-line interface for generating .gitignore files",
|
Short: "A command-line interface for generating .gitignore files",
|
||||||
Long: `ignr-cli is a command-line interface for generating .gitignore files.
|
Long: `ignr is a command-line interface for generating .gitignore files.
|
||||||
It allows users to easily create and manage .gitignore files for various programming languages and frameworks.
|
It allows users to easily create and manage .gitignore files for various programming languages and frameworks.
|
||||||
You may also list available templates and generate .gitignore files based on those templates.`,
|
You may also list available templates and generate .gitignore files based on those templates.`,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
@@ -43,7 +43,7 @@ You may also list available templates and generate .gitignore files based on tho
|
|||||||
}
|
}
|
||||||
version = strings.Split(info.Main.Version, "-")[0]
|
version = strings.Split(info.Main.Version, "-")[0]
|
||||||
}
|
}
|
||||||
fmt.Printf("ignr-cli version: %s\n", version)
|
fmt.Printf("ignr version: %s\n", version)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
new.go
8
new.go
@@ -67,7 +67,7 @@ func runPrompt(client *github.Client, height int) (*github.Gitignore, error) {
|
|||||||
return nil, fmt.Errorf("error retrieving gitignore template list: %w", err)
|
return nil, fmt.Errorf("error retrieving gitignore template list: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
selectTemmplates := &promptui.SelectTemplates{
|
selectTemplates := &promptui.SelectTemplates{
|
||||||
Label: ` {{ "\U0000007C" | faint }} {{ . | magenta | bold }}`,
|
Label: ` {{ "\U0000007C" | faint }} {{ . | magenta | bold }}`,
|
||||||
Active: `{{ "\U0000007C" | faint }} {{ "🌶" | red }} {{ . | cyan | italic }}`,
|
Active: `{{ "\U0000007C" | faint }} {{ "🌶" | red }} {{ . | cyan | italic }}`,
|
||||||
Inactive: `{{ "\U0000007C" | faint }} {{ . | faint }}`,
|
Inactive: `{{ "\U0000007C" | faint }} {{ . | faint }}`,
|
||||||
@@ -77,7 +77,7 @@ func runPrompt(client *github.Client, height int) (*github.Gitignore, error) {
|
|||||||
prompt := promptui.Select{
|
prompt := promptui.Select{
|
||||||
Label: "Select a .gitignore template",
|
Label: "Select a .gitignore template",
|
||||||
Items: templates,
|
Items: templates,
|
||||||
Templates: selectTemmplates,
|
Templates: selectTemplates,
|
||||||
Size: height,
|
Size: height,
|
||||||
Searcher: filterFunc(templates),
|
Searcher: filterFunc(templates),
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ func runPrompt(client *github.Client, height int) (*github.Gitignore, error) {
|
|||||||
|
|
||||||
// commitGitignore writes the content of the selected gitignore template to the .gitignore file.
|
// commitGitignore writes the content of the selected gitignore template to the .gitignore file.
|
||||||
func commitGitignore(content *github.Gitignore, w io.Writer) error {
|
func commitGitignore(content *github.Gitignore, w io.Writer) error {
|
||||||
if _, err := fmt.Fprintf(w, "# Generated by ignr-cli: github.com/onyx-and-iris/ignr-cli\n\n## %s ##\n", content.GetName()); err != nil {
|
if _, err := fmt.Fprintf(w, "# Generated by ignr: github.com/onyx-and-iris/ignr\n\n## %s ##\n", content.GetName()); err != nil {
|
||||||
return fmt.Errorf("error writing header to file '%s': %w", gitignoreFileName, err)
|
return fmt.Errorf("error writing header to file '%s': %w", gitignoreFileName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ func commitGitignore(content *github.Gitignore, w io.Writer) error {
|
|||||||
return fmt.Errorf("error writing to file '%s': %w", gitignoreFileName, err)
|
return fmt.Errorf("error writing to file '%s': %w", gitignoreFileName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := fmt.Fprintf(w, "\n# End of ignr-cli\n"); err != nil {
|
if _, err := fmt.Fprintf(w, "\n# End of ignr\n"); err != nil {
|
||||||
return fmt.Errorf("error writing footer to file '%s': %w", gitignoreFileName, err)
|
return fmt.Errorf("error writing footer to file '%s': %w", gitignoreFileName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user