From 6143178441af5d4562b84ed55586f2149bedf0a0 Mon Sep 17 00:00:00 2001 From: Roytangrb Date: Sat, 16 Jan 2021 23:16:27 +0800 Subject: [PATCH] chore(release): v0.1.2 --- README.md | 5 ++++- cmd/root.go | 15 ++++++++++----- cmd/version.go | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a45314d..b0d50f7 100644 --- a/README.md +++ b/README.md @@ -103,4 +103,7 @@ You will be prompted for selecting/entering each commit message component. > coming soon ## Reference -* [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) \ No newline at end of file +* [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) +* [Cobra](https://github.com/spf13/cobra) +* [Survey](https://github.com/AlecAivazis/survey) +* [Carbon](https://carbon.now.sh/) \ No newline at end of file diff --git a/cmd/root.go b/cmd/root.go index 27d9a26..bba3905 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,6 +10,11 @@ import ( "github.com/spf13/viper" ) +// VersionTmpl version template for --version output +const VersionTmpl = ` +{{- .Name}} {{.Version}} +` + var ( cfgFile string isVerbose bool @@ -20,7 +25,7 @@ var logger *util.Logger = util.InitLogger(os.Stdout, os.Stdout, os.Stdout, os.St // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "gitwok", - Version: "v0.1.0", + Version: "v0.1.2", Short: "Configurable CLI with conventional commits, changelog, git hooks all in one", Run: func(cmd *cobra.Command, args []string) {}, } @@ -34,7 +39,7 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) - rootCmd.SetVersionTemplate("{{.Name}} {{.Version}}\n") + rootCmd.SetVersionTemplate(VersionTmpl) rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./gitwok.yaml)") rootCmd.PersistentFlags().BoolVarP(&isVerbose, "verbose", "v", false, "verbose output") @@ -65,11 +70,11 @@ func initConfig() { logger.Verbose("Using config file", viper.ConfigFileUsed()) } else { if fnfe, ok := err.(viper.ConfigFileNotFoundError); ok { - logger.Error(fnfe) + logger.Warn(fnfe) } else if pe, ok := err.(viper.ConfigParseError); ok { - logger.Error(pe) + logger.Warn(pe) } else { - logger.Error(err) + logger.Warn(err) } } } diff --git a/cmd/version.go b/cmd/version.go index 19478a5..59aed23 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -22,5 +22,5 @@ func init() { } func printlnVer(name string, semver string) { - fmt.Printf("%s %s\n", name, semver) + fmt.Print(fmt.Sprintln(name, semver)) }