Skip to content

Commit

Permalink
command: add ProgramName helper
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Mar 10, 2024
1 parent f058c6f commit 64b71fd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import (
"time"
)

// ProgramName returns the base name of the currently-running executable.
func ProgramName() string {
if p, err := os.Executable(); err == nil {
return filepath.Base(p)
}
return filepath.Base(os.Args[0])
}

// VersionCommand constructs a standardized version command that prints version
// metadata from the running binary to stdout. The caller can safely modify the
// returned command to customize its behavior.
Expand Down

0 comments on commit 64b71fd

Please sign in to comment.