Skip to content

Commit

Permalink
add version command
Browse files Browse the repository at this point in the history
  • Loading branch information
flexphere committed Jun 28, 2024
1 parent 679ae73 commit 04384cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ it adds a custom configuration per repository to specify the worktree path and c

### Installation
```sh
go install github.com/flexphere/gw@latest
go install github.com/flexphere/gw@0.0.2
```

### Usage

#### Setup current repository
```sh
gw init \
--worktree-path ~/.worktree \ # setup current repository to create its worktrees underworktree
--worktree-path ~/.worktree \ # setup current repository to create its worktrees under "~/.worktree"
--cmd "echo hello" --cmd "echo world" # run `echo hello` and `echo world` on worktree creation
```

Expand All @@ -25,9 +25,9 @@ gw init \
gw new name-of-worktree
```

#### Edit config
#### Editing the config
```sh
gw edit
gw edit # opens the config file in the editor
```

#### Passthrough
Expand Down
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"log"
"os"

Expand Down Expand Up @@ -30,6 +31,10 @@ func Execute() {
}
}

func SetVersionInfo(version, commit, date string) {
rootCmd.Version = fmt.Sprintf("%s (Built on %s from Git SHA %s)", version, date, commit)
}

func init() {
rootCmd.AddCommand(newCmd)
rootCmd.AddCommand(editCmd)
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ package main

import "github.com/flexphere/gw/cmd"

var (
version = "dev"
commit = "none"
date = "unknown"
)

func main() {
cmd.SetVersionInfo(version, commit, date)
cmd.Execute()
}

0 comments on commit 04384cd

Please sign in to comment.