mirror of
https://github.com/onyx-and-iris/gignore.git
synced 2025-03-31 10:51:19 +01:00
Compare commits
3 Commits
a3c2d2cfbf
...
626e40b653
Author | SHA1 | Date | |
---|---|---|---|
626e40b653 | |||
fd9c7194c1 | |||
388a204299 |
16
CHANGELOG.md
16
CHANGELOG.md
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user