3 Commits

Author SHA1 Message Date
e1b879f54c change default height to 10
- with startswith filtering its more reasonable
2025-06-18 06:37:06 +01:00
f51302a945 update usage, header + footer. 2025-06-18 06:26:34 +01:00
11fe797f3f upd go.mod to match repository 2025-06-18 06:13:01 +01:00
5 changed files with 11 additions and 11 deletions

4
.gitignore vendored
View File

@@ -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

View File

@@ -20,7 +20,7 @@ go install github.com/onyx-and-iris/ignr@latest
- --token/-t: GitHub authentication token - --token/-t: GitHub authentication token
- note, this tool can be used **without** authenticating but rate limiting will be stricter. - note, this tool can be used **without** authenticating but rate limiting will be stricter.
- --height/-H: Height of the selection prompt (default 20) - --height/-H: Height of the selection prompt (default 10)
- --filter/-f: Type of filter to apply to the list of templates (default startswith) - --filter/-f: Type of filter to apply to the list of templates (default startswith)
- may be one of (startswith, contains) - may be one of (startswith, contains)
@@ -30,7 +30,7 @@ go install github.com/onyx-and-iris/ignr@latest
#!/usr/bin/env bash #!/usr/bin/env bash
export IGNR_TOKEN=<API Token> export IGNR_TOKEN=<API Token>
export IGNR_HEIGHT=20 export IGNR_HEIGHT=10
export IGNR_FILTER=startswith export IGNR_FILTER=startswith
``` ```

2
go.mod
View File

@@ -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

View File

@@ -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
} }
@@ -54,7 +54,7 @@ You may also list available templates and generate .gitignore files based on tho
// init initialises the root command and its flags. // init initialises the root command and its flags.
func init() { func init() {
rootCmd.PersistentFlags().StringP("token", "t", "", "GitHub authentication token") rootCmd.PersistentFlags().StringP("token", "t", "", "GitHub authentication token")
rootCmd.PersistentFlags().IntP("height", "H", 20, "Height of the selection prompt") rootCmd.PersistentFlags().IntP("height", "H", 10, "Height of the selection prompt")
rootCmd.PersistentFlags(). rootCmd.PersistentFlags().
StringP("filter", "f", "startswith", "Type of filter to apply to the list of templates (e.g., 'startswith', 'contains')") StringP("filter", "f", "startswith", "Type of filter to apply to the list of templates (e.g., 'startswith', 'contains')")

4
new.go
View File

@@ -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)
} }