|
|
@ -21,22 +21,22 @@ import (
|
|
|
|
"github.com/q191201771/naza/pkg/nazalog"
|
|
|
|
"github.com/q191201771/naza/pkg/nazalog"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var licenseTmpl = `// Copyright %d, Chef. All rights reserved.
|
|
|
|
var licenseTmpl = `// Copyright %d, %s. All rights reserved.
|
|
|
|
// https://%s
|
|
|
|
// https://%s
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a MIT-style license
|
|
|
|
// Use of this source code is governed by a MIT-style license
|
|
|
|
// that can be found in the License file.
|
|
|
|
// that can be found in the License file.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Author: Chef (191201771@qq.com)
|
|
|
|
// Author: %s (%s)
|
|
|
|
|
|
|
|
|
|
|
|
`
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
func main() {
|
|
|
|
dir := parseFlag()
|
|
|
|
dir, name, email := parseFlag()
|
|
|
|
|
|
|
|
|
|
|
|
year := time.Now().Year()
|
|
|
|
year := time.Now().Year()
|
|
|
|
repo := achieveRepo(dir)
|
|
|
|
repo := achieveRepo(dir)
|
|
|
|
license := fmt.Sprintf(licenseTmpl, year, repo)
|
|
|
|
license := fmt.Sprintf(licenseTmpl, year, name, repo, name, email)
|
|
|
|
nazalog.Debug(license)
|
|
|
|
nazalog.Debug(license)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
@ -67,12 +67,14 @@ func achieveRepo(root string) string {
|
|
|
|
return string(bytes.TrimSpace(repo))
|
|
|
|
return string(bytes.TrimSpace(repo))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func parseFlag() string {
|
|
|
|
func parseFlag() (string, string, string) {
|
|
|
|
dir := flag.String("d", "", "dir of repo")
|
|
|
|
dir := flag.String("d", "", "dir of repo")
|
|
|
|
|
|
|
|
name := flag.String("n", "", "user name")
|
|
|
|
|
|
|
|
email := flag.String("e", "", "user email")
|
|
|
|
flag.Parse()
|
|
|
|
flag.Parse()
|
|
|
|
if *dir == "" {
|
|
|
|
if *dir == "" || *name == "" || *email == "" {
|
|
|
|
flag.Usage()
|
|
|
|
flag.Usage()
|
|
|
|
os.Exit(1)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *dir
|
|
|
|
return *dir, *name, *email
|
|
|
|
}
|
|
|
|
}
|
|
|
|