mirror of
https://github.com/chenasraf/gi_gen.git
synced 2026-05-17 17:48:01 +00:00
updates
This commit is contained in:
8
.editorconfig
Normal file
8
.editorconfig
Normal file
@@ -0,0 +1,8 @@
|
||||
[*]
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
5
README.md
Normal file
5
README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Gitignore File Generator
|
||||
|
||||
You can run this CLI program to create or append a .gitignore template easily.
|
||||
|
||||
Just run `gi_gen` in the directory you wish to add to and follow the prompts.
|
||||
14
gi_gen.go
14
gi_gen.go
@@ -14,6 +14,10 @@ import (
|
||||
// create line cache map for skipping previously checked glob lines
|
||||
var lineCache = make(map[string]bool)
|
||||
|
||||
func quit() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
allFiles, err := prepareGitignores()
|
||||
|
||||
@@ -29,7 +33,7 @@ func main() {
|
||||
|
||||
if findFileMatches(contents) {
|
||||
sep := "#========================================================================\n"
|
||||
header := fmt.Sprintf(sep+"# %s\n"+sep+"\n", basename)
|
||||
header := fmt.Sprintf(sep+"# %s\n"+sep+"\n", langName)
|
||||
files[langName] = header + contents
|
||||
fileNames = append(fileNames, langName)
|
||||
}
|
||||
@@ -48,6 +52,9 @@ func main() {
|
||||
|
||||
var inp []string
|
||||
survey.AskOne(prompt, &inp)
|
||||
if inp == nil {
|
||||
quit()
|
||||
}
|
||||
|
||||
for _, sel := range inp {
|
||||
selected = append(selected, files[sel])
|
||||
@@ -64,9 +71,12 @@ func main() {
|
||||
Message: ".gitignore file found in this directory. Please pick an option:",
|
||||
Options: []string{"Overwrite", "Append", "Skip"},
|
||||
}
|
||||
var inp2 string
|
||||
inp2 := ""
|
||||
survey.AskOne(prompt2, &inp2)
|
||||
switch inp2 {
|
||||
case "":
|
||||
quit()
|
||||
break
|
||||
case "Overwrite":
|
||||
log.Printf("Writing to %s", out)
|
||||
writeFile(out, strings.Join(selected, "\n"), true)
|
||||
|
||||
Reference in New Issue
Block a user