Compare commits

..

No commits in common. "626e40b653059fe47370962299b4944dbeb97d78" and "a3c2d2cfbfb4bc7b19f9b2f5d39b7f0c2c36da93" have entirely different histories.

3 changed files with 11 additions and 28 deletions

View File

@ -5,22 +5,6 @@ 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/), 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). 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 # [0.1.0] - 2025-09-03
### Added ### Added

View File

@ -16,14 +16,14 @@ func main() {
w := flag.CommandLine.Output() w := flag.CommandLine.Output()
fmt.Fprint(w, "Usage of gignore:\n") fmt.Fprint(w, "Usage of gignore:\n")
fmt.Fprint(w, " gignore [flags] <template>\n") fmt.Fprintf(w, " gignore [flags] <template>\n")
fmt.Fprint(w, "\n") fmt.Fprint(w, "\n")
fmt.Fprint(w, "Flags:\n") fmt.Fprint(w, "Flags:\n")
flag.PrintDefaults() flag.PrintDefaults()
fmt.Fprint(w, "\n") fmt.Fprint(w, "\n")
fmt.Fprint(w, "Example:\n") fmt.Fprintf(w, "Example:\n")
fmt.Fprint(w, " gignore go\n") fmt.Fprint(w, " gignore go\n")
} }
@ -59,18 +59,17 @@ func main() {
} }
args := flag.Args() args := flag.Args()
if len(args) == 0 { if len(args) != 1 {
flag.Usage() flag.Usage()
return return
} }
for _, arg := range args { err := client.Create(args[0])
err := client.Create(arg) if err != nil {
if err != nil { log.Fatalf("failed to create .gitignore file: %v", err)
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 { 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) { func (fw *FileWriter) Write(content []byte) (int, error) {
f, err := os.OpenFile(fw.targetFileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o600) f, err := os.Create(fw.targetFileName)
if err != nil { if err != nil {
return 0, err return 0, err
} }
defer f.Close() defer f.Close()
const header = "# Auto-generated .gitignore by gignore: github.com/onyx-and-iris/gignore\n" const header = `# Auto-generated .gitignore by gignore: github.com/onyx-and-iris/gignore`
const footer = "\n# End of gignore: github.com/onyx-and-iris/gignore\n" const footer = `# End of gignore: github.com/onyx-and-iris/gignore`
var sz int64 var sz int64
n, err := fw.writeContent([]byte(header), f) n, err := fw.writeContent([]byte(header), f)