Skip to content

Commit

Permalink
Show version (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
strehle authored Nov 22, 2024
1 parent dfb10af commit 0541de3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cmd/openid-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func main() {
" authorization_code Perform authorization code flow.\n" +
" client_credentials Perform client credentials flow.\n" +
" password Perform resource owner flow, also known as password flow.\n" +
" version Show version.\n" +
" help Show this help for more details.\n" +
"\n" +
"Flags:\n" +
Expand Down Expand Up @@ -80,6 +81,7 @@ func main() {
var clientJwtX5t = flag.String("client_jwt_x5t", "", "X5T Header in client JWT for private_key_jwt authentication")
var userName = flag.String("username", "", "User name for command password grant required, else optional")
var userPassword = flag.String("password", "", "User password for command password grant required, else optional")
var doVersion = flag.Bool("version", false, "Show version")
var appTid = flag.String("app_tid", "", "Application tenant ID")
var command = flag.String("cmd", "", "Single command to be executed")
var mTLS bool = false
Expand All @@ -97,7 +99,7 @@ func main() {
flag.Usage()
return
case "version":
fmt.Println("openid-client version:", version, "commit:", commit, "built at:", date)
showVersion()
return
case "client_credentials", "password", "":
case "authorization_code":
Expand All @@ -106,6 +108,10 @@ func main() {
log.Fatal("Invalid command, see usage (-h)")
}
if *command != "jwks" {
if *doVersion {
showVersion()
return
}
if *issEndPoint == "" {
log.Fatal("issuer is required to run this command")
} else if *clientID == "" {
Expand Down Expand Up @@ -309,3 +315,11 @@ func main() {
}
}
}

func showVersion() {
if date != "" && date != "unknown" {
fmt.Println("openid-client version:", version, "commit:", commit, "built at:", date)
} else {
fmt.Println("openid-client version:", version, "commit:", commit)
}
}

0 comments on commit 0541de3

Please sign in to comment.