Skip to content

Commit

Permalink
Merge pull request #8 from msh5/support-version-flag
Browse files Browse the repository at this point in the history
Support version flag
  • Loading branch information
msh5 committed Nov 18, 2019
2 parents 4e511f6 + b185aab commit eccced9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Release

on:
release:
types: [published]

jobs:
goreleaser:
Expand Down
5 changes: 4 additions & 1 deletion interface/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ var cfgFile string
var rootCmd = &cobra.Command{
Use: "boy",
Short: "On-cloud snippet runner",
Long: `TODO`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}

func SetVersion(version string) {
rootCmd.Version = version
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
Expand Down
31 changes: 17 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
/*
Copyright © 2019 NAME HERE <EMAIL ADDRESS>
package main

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
import (
"fmt"

http://www.apache.org/licenses/LICENSE-2.0
"github.com/msh5/boy/interface/cmd"
)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
// "version", "commit" and "date" variables are overridden by goreleaser.

import "github.com/msh5/boy/interface/cmd"
var (
version = "dev"
commit = "none" // nolint:gochecknoglobals
date = "unknown" // nolint:gochecknoglobals
)

func formatVersionString() string {
return fmt.Sprintf("%v, commit %v, built at %v", version, commit, date)
}

func main() {
cmd.SetVersion(formatVersionString())

cmd.Execute()
}

0 comments on commit eccced9

Please sign in to comment.