Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
orangekame3 committed Oct 7, 2023
1 parent 350d683 commit 77ebbe5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .tagpr
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
[tagpr]
vPrefix = true
releaseBranch = main
versionFile = version.go
versionFile = cmd/version.go
9 changes: 3 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ This application is a tool to generate the needed files
to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("rootCmd called")
},
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand All @@ -64,8 +66,3 @@ func init() {
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

// SetVersionInfo sets version and date to rootCmd
func SetVersionInfo(version, date string) {
rootCmd.Version = fmt.Sprintf("%s (Built on %s)", version, date)
}
11 changes: 9 additions & 2 deletions version.go → cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package main
package cmd

const version = "0.0.1"
import "fmt"

const Version = "0.0.1"

// SetVersionInfo sets version and date to rootCmd
func SetVersionInfo(version, date string) {
rootCmd.Version = fmt.Sprintf("%s (Built on %s)", version, date)
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ import (
)

func main() {
cmd.SetVersionInfo(version, time.Now().String())
cmd.SetVersionInfo(cmd.Version, time.Now().String())
cmd.Execute()
}

0 comments on commit 77ebbe5

Please sign in to comment.