Compare commits
2 Commits
e415f8bcae
...
75c29b4ed4
Author | SHA1 | Date | |
---|---|---|---|
75c29b4ed4 | |||
54b5760769 |
13
main.go
13
main.go
@ -1,11 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
@ -19,9 +17,6 @@ type LicensingData struct {
|
|||||||
Year int
|
Year int
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:embed all:templates
|
|
||||||
var Templates embed.FS
|
|
||||||
|
|
||||||
var GitConfigError = errors.New("Can't read Git config")
|
var GitConfigError = errors.New("Can't read Git config")
|
||||||
var NotSupportedError = errors.New("Not supported license")
|
var NotSupportedError = errors.New("Not supported license")
|
||||||
|
|
||||||
@ -41,7 +36,11 @@ func getGitUserData() (string, string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getTemplateList() []string {
|
func getTemplateList() []string {
|
||||||
files, err := fs.ReadDir(Templates, "templates")
|
d, err := os.Open("templates")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
files, err := d.Readdir(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -61,7 +60,7 @@ func listTemplates() {
|
|||||||
|
|
||||||
func genLicense(lcnsName string, lcnsData LicensingData, outFileName string) error {
|
func genLicense(lcnsName string, lcnsData LicensingData, outFileName string) error {
|
||||||
tmplFile := "templates/" + lcnsName + ".tmpl"
|
tmplFile := "templates/" + lcnsName + ".tmpl"
|
||||||
tmpl, err := template.ParseFS(Templates, tmplFile)
|
tmpl, err := template.ParseFiles(tmplFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return NotSupportedError
|
return NotSupportedError
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user