Skip to content

Commit

Permalink
Add version command.
Browse files Browse the repository at this point in the history
Signed-off-by: Vaibhav <[email protected]>
  • Loading branch information
vrongmeal committed Feb 23, 2020
1 parent 73857c8 commit ff0e663
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
1 change: 0 additions & 1 deletion .leaf.yml → _examples/sample.leaf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ filters:
# Commands to be executed.
# These are run in the provided order.
exec:
- ["make", "format"]
- ["make", "build"]

# Delay after which commands are executed.
Expand Down
17 changes: 17 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package main

import (
"fmt"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/vrongmeal/leaf/pkg/engine"
"github.com/vrongmeal/leaf/pkg/utils"
"github.com/vrongmeal/leaf/version"

prefixed "github.com/x-cray/logrus-prefixed-formatter"
)
Expand Down Expand Up @@ -41,13 +44,27 @@ order so you don't have to yourself`,
}
},
}

versionCmd = &cobra.Command{
Use: "version",
Short: "Leaf version",
Long: `Leaf version details`,

Run: func(*cobra.Command, []string) {
fmt.Printf(`%s: %s
Version [%s]
`, version.AppName, rootCmd.Short, version.Version)
},
}
)

func init() {
logrus.SetLevel(logrus.TraceLevel)
logrus.SetFormatter(new(prefixed.TextFormatter))

rootCmd.PersistentFlags().StringVarP(&confPath, "config", "c", utils.DefaultConfPath, "Config path for leaf configuration file")

rootCmd.AddCommand(versionCmd)
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ app_name="leaf"
repo_path="github.com/vrongmeal/leaf"

# Get branch revision and version
version="0.1.0"
version="1.0.0"
revision=$(git rev-parse --short HEAD 2> /dev/null || echo 'unknown')
branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown')

Expand Down
10 changes: 2 additions & 8 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
#!/bin/bash

set -e

pkgs=$(go list ./... | grep -v vendor)

echo "* Linting code for errors"

# Vet first since golangci-lint returns unclear errors if packages don't build
go vet ${pkgs}

# Exit if vet throws an error
vet_status="$?"

if [ "$vet_status" -ne 0 ]
then
exit "$vet_status"
fi

golangci-lint run

echo "+ Your code is beautiful!"
Expand Down

0 comments on commit ff0e663

Please sign in to comment.