Skip to content

Commit 279e638

Browse files
committed
Allow changing the app name at compile time through AppName
1 parent 1932842 commit 279e638

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

cmd/step/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ var Version = "N/A"
1717
// the time of build
1818
var BuildTime = "N/A"
1919

20+
// AppName is the name of the binary. Defaults to "step" if not set.
21+
var AppName = ""
22+
2023
func init() {
2124
step.Set("Smallstep CLI", Version, BuildTime)
2225
ca.UserAgent = step.Version()
26+
cmd.SetName(AppName)
2327
}
2428

2529
func main() {

internal/cmd/root.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ func Run() int {
8080
return 0
8181
}
8282

83+
var (
84+
stepAppName = "step"
85+
)
86+
87+
func SetName(appName string) {
88+
if appName != "" {
89+
stepAppName = appName
90+
}
91+
}
92+
8393
func newApp(stdout, stderr io.Writer) *cli.App {
8494
// Define default file writers and prompters for go.step.sm/crypto
8595
pemutil.WriteFile = utils.WriteFile
@@ -103,8 +113,8 @@ func newApp(stdout, stderr io.Writer) *cli.App {
103113

104114
// Configure cli app
105115
app := cli.NewApp()
106-
app.Name = "step"
107-
app.HelpName = "step"
116+
app.Name = stepAppName // "step" by default
117+
app.HelpName = stepAppName // "step" by default
108118
app.Usage = "plumbing for distributed systems"
109119
app.Version = step.Version()
110120
app.Commands = command.Retrieve()

0 commit comments

Comments
 (0)