Compare commits

...

3 Commits

Author SHA1 Message Date
626e40b653 add 0.2.0 and 0.3.0 to CHANGELOG
Some checks failed
CI / Lint (push) Has been cancelled
2025-03-14 21:58:57 +00:00
fd9c7194c1 CLI may now accept multiple template names 2025-03-14 21:53:06 +00:00
388a204299 open file in append mode 2025-03-14 21:49:55 +00:00
3 changed files with 28 additions and 11 deletions

View File

@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# [0.3.0] - 2024-14-03
### Added
- CLI may now accept multiple template names, example `gignore go python`. One will be appended after the other.
### Changed
- Filewriter now opens file in append mode.
# [0.2.0] - 2025-10-03
### Fixed
- Template .gitignore are now written concurrently.
# [0.1.0] - 2025-09-03
### Added

View File

@ -16,14 +16,14 @@ func main() {
w := flag.CommandLine.Output()
fmt.Fprint(w, "Usage of gignore:\n")
fmt.Fprintf(w, " gignore [flags] <template>\n")
fmt.Fprint(w, " gignore [flags] <template>\n")
fmt.Fprint(w, "\n")
fmt.Fprint(w, "Flags:\n")
flag.PrintDefaults()
fmt.Fprint(w, "\n")
fmt.Fprintf(w, "Example:\n")
fmt.Fprint(w, "Example:\n")
fmt.Fprint(w, " gignore go\n")
}
@ -59,17 +59,18 @@ func main() {
}
args := flag.Args()
if len(args) != 1 {
if len(args) == 0 {
flag.Usage()
return
}
err := client.Create(args[0])
if err != nil {
log.Fatalf("failed to create .gitignore file: %v", err)
for _, arg := range args {
err := client.Create(arg)
if err != nil {
log.Fatalf("failed to create .gitignore file: %v", err)
}
fmt.Printf("√ created %s .gitignore file\n", arg)
}
fmt.Printf("√ created %s .gitignore file\n", args[0])
}
func listTemplates(client *gignore.Client) error {

View File

@ -29,14 +29,14 @@ func (fw *FileWriter) writeContent(content []byte, dst io.Writer) (int64, error)
}
func (fw *FileWriter) Write(content []byte) (int, error) {
f, err := os.Create(fw.targetFileName)
f, err := os.OpenFile(fw.targetFileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o600)
if err != nil {
return 0, err
}
defer f.Close()
const header = `# Auto-generated .gitignore by gignore: github.com/onyx-and-iris/gignore`
const footer = `# End of gignore: github.com/onyx-and-iris/gignore`
const header = "# Auto-generated .gitignore by gignore: github.com/onyx-and-iris/gignore\n"
const footer = "\n# End of gignore: github.com/onyx-and-iris/gignore\n"
var sz int64
n, err := fw.writeContent([]byte(header), f)