Skip to content

Commit

Permalink
Merge pull request #2513 from kyparisisg/cli-config
Browse files Browse the repository at this point in the history
Add build-time support for customizable default API and URL endpoints
  • Loading branch information
jhaals authored Oct 18, 2024
2 parents 9f4c04b + ddc3a87 commit d6a08d9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/yopass/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ Examples:
Website: %s
`

var (
defaultAPI = "https://api.yopass.se"
defaultURL = "https://yopass.se"
)

func init() {
// Defaults
viper.SetDefault("api", "https://api.yopass.se")
viper.SetDefault("url", "https://yopass.se")
// Use build-time values if set; otherwise, fall back to hardcoded defaults.
// Build with -ldflags "-X main.defaultAPI=https://your-custom-api.com -X main.defaultURL=https://your-custom-url.com" to override defaults
viper.SetDefault("api", defaultAPI)
viper.SetDefault("url", defaultURL)
viper.SetDefault("one-time", true)
viper.SetDefault("expiration", "1h")

Expand Down

0 comments on commit d6a08d9

Please sign in to comment.