Skip to content

Commit

Permalink
Add version subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
alebeck committed Dec 14, 2024
1 parent d6bc63a commit 043003e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions cmd/boring/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func main() {
listTunnels()
case "edit", "e":
openConfig()
case "version", "v":
printVersion()
default:
log.Printf("Unknown command: %v\n", os.Args[1])
printUsage()
Expand Down Expand Up @@ -79,21 +81,25 @@ func initLogging() {
log.Init(os.Stdout, isTerm, useColors)
}

func printUsage() {
func printVersion() {
v := version
if v == "" {
v = "snapshot"
if commit != "" {
v += fmt.Sprintf(" (#%s)", commit)
}
}
log.Emitf("boring %s\n", v)
}

log.Printf("boring %s\n", v)
func printUsage() {
log.Printf("The `boring` SSH tunnel manager.\n\n")
log.Printf("Usage:\n")
log.Printf(" boring list, l List all tunnels\n")
log.Printf(` boring open, o (-a | <patterns>...)
<patterns>... Open tunnels matching any glob pattern
-a, --all Open all tunnels` + "\n")
log.Printf(" boring close, c Close tunnels (same options as 'open')\n")
log.Printf(" boring edit, e Edit the configuration file\n")
log.Printf(" boring version, v Show the version number\n")
}
2 changes: 1 addition & 1 deletion completions/boring.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ _boring() {
local cur cmd
cur="${COMP_WORDS[COMP_CWORD]}"

local commands=("open" "close" "list" "edit")
local commands=("open" "close" "list" "edit" "version")

_boring_get_names() {
local status="$1"
Expand Down
2 changes: 1 addition & 1 deletion completions/boring.fish
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function __boring_complete
set arguments (commandline -opc)[3..-1]

if test (count $command) -eq 0
printf "%s\n" open close list edit
printf "%s\n" open close list edit version
return
end

Expand Down
1 change: 1 addition & 0 deletions completions/boring.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ _boring() {
"close"
"list"
"edit"
"version"
)

_boring_get_names() {
Expand Down

0 comments on commit 043003e

Please sign in to comment.