Skip to content

Commit

Permalink
add version print option
Browse files Browse the repository at this point in the history
  • Loading branch information
acarl005 committed Oct 13, 2022
1 parent aa948e9 commit 00b5ce6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions arguments.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// declare the struct that holds all the arguments
type arguments struct {
paths *[]string
version *bool
all *bool
bytes *bool
mdate *bool
Expand All @@ -34,6 +35,7 @@ type arguments struct {

var args = arguments{
kingpin.Arg("paths", "the files(s) and/or folder(s) to display").Default(".").Strings(),
kingpin.Flag("version", "print version and exit").Short('v').Bool(),
kingpin.Flag("all", "show hidden files").Short('a').Bool(),
kingpin.Flag("bytes", "include size").Short('b').Bool(),
kingpin.Flag("mdate", "include modification date").Short('m').Bool(),
Expand Down
8 changes: 8 additions & 0 deletions ls-go.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)

const VERSION = "0.2.3"

// DisplayItem wraps the file stat info and string to be printed
type DisplayItem struct {
display string
Expand Down Expand Up @@ -63,6 +65,12 @@ func main() {
// parse the arguments and populate the struct
kingpin.Parse()
argsPostParse()

if *args.version {
fmt.Println("v" + VERSION)
return
}

generateColors()

// separate the directories from the regular files
Expand Down
3 changes: 2 additions & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ if ! command -v gh >/dev/null; then
exit 1
fi

TAG=0.2.2
TAG=$(grep 'VERSION =' ls-go.go | grep -oE '\d+\.\d+.\d+')

git tag --force latest
git tag -a v$TAG -m "release v$TAG"

git push origin master --tags
Expand Down

0 comments on commit 00b5ce6

Please sign in to comment.