-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd/file_templates/go_cli_project): Add Goreleaser & Dockerfiles
- Loading branch information
1 parent
c8a37dd
commit 273c1f9
Showing
2 changed files
with
183 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,17 +14,33 @@ import ( | |
var CmdFlagPathPrefix string | ||
var CmdFlagProjectName string | ||
var CmdFlagPackage string | ||
var CmdFlagMaintainer string | ||
var CmdFlagBrewOrganization string | ||
var CmdFlagBrewRepo string | ||
var CmdFlagDockerRegistry string | ||
|
||
type TemplateVariables struct { | ||
ProjectName string | ||
Package string | ||
ProjectName string | ||
Package string | ||
Maintainer string | ||
BrewOrganization string | ||
BrewRepo string | ||
DockerRegistry string | ||
} | ||
|
||
var Cmd = &cobra.Command{ | ||
Use: "go-cli-project", | ||
Short: "Create Golang CLI project", | ||
Args: cobra.NoArgs, | ||
Run: func(c *cobra.Command, args []string) { | ||
tv := TemplateVariables{ | ||
ProjectName: CmdFlagProjectName, | ||
Package: CmdFlagPackage, | ||
Maintainer: CmdFlagMaintainer, | ||
BrewOrganization: CmdFlagBrewOrganization, | ||
BrewRepo: CmdFlagBrewRepo, | ||
DockerRegistry: CmdFlagDockerRegistry, | ||
} | ||
for filename, content := range Files { | ||
_ = content | ||
fullPath := path.Join(CmdFlagPathPrefix, filename) | ||
|
@@ -41,10 +57,7 @@ var Cmd = &cobra.Command{ | |
panic(err) | ||
} | ||
defer f.Close() | ||
t.Execute(f, TemplateVariables{ | ||
ProjectName: CmdFlagProjectName, | ||
Package: CmdFlagPackage, | ||
}) | ||
t.Execute(f, tv) | ||
} | ||
}, | ||
} | ||
|
@@ -73,4 +86,28 @@ func init() { | |
"Package {{.Package}}", | ||
) | ||
Cmd.MarkFlagRequired("package") | ||
Cmd.Flags().StringVar( | ||
&CmdFlagMaintainer, | ||
"maintainer", | ||
"SikaLabs Opensource <[email protected]>", | ||
"Package {{.Maintainer}}", | ||
) | ||
Cmd.Flags().StringVar( | ||
&CmdFlagBrewOrganization, | ||
"brew-org", | ||
"sikalabs", | ||
"Package {{.BrewOrganization}}", | ||
) | ||
Cmd.Flags().StringVar( | ||
&CmdFlagBrewRepo, | ||
"brew-repo", | ||
"homebrew-tap", | ||
"Package {{.BrewRepo}}", | ||
) | ||
Cmd.Flags().StringVar( | ||
&CmdFlagDockerRegistry, | ||
"docker-registry", | ||
"homebrew-tap", | ||
"Package {{.DockerRegistry}}", | ||
) | ||
} |