Support the ability to create a link in the user menu from an env variable
The user should be able to specify a link that will show up in the user menu, e.g. USER_LINK_NAME="foo" USER_LINK_URL="http://foo.com"
This will add a menu item named foo, that when clicked will take the user to the specified link
@nhaugo This could go a couple of ways:
- as a flag, like --custom-links=foo:https://foo.com,bar:https://bar.com -- but this feels semantically like a one-time config, required every time a server process is run, rather than persistent or additive
- as a sub command, like add-source foo=https://foo.com,bar=http://bar.com
If the second option, I think it feels more like an additive operation, so that you could add one or more sources once and it would continue to be a custom link in your USER menu from bar point onward, and you could add more sources any time.
The first requires much less work.
The second would require parsing a sub command and persisting links to the database. I'm eager to try this, but it entails much more work.
Which do you prefer? Or, do you have another desired direction?
I actually prefer the first it is much more operator friendly. Stateful commands are much harder to manage for deployment.
Ok, thanks. I'll do an iteration on the first and we can see how it feels.
@jaredscheib here is how I would do it:
package main
import (
"log"
"os"
"github.com/jessevdk/go-flags"
)
type Options struct {
// Example of map with multiple default values
Users map[string]string `long:"users" description:"User e-mail map" default:"system:[email protected]" default:"admin:[email protected]"`
}
var options Options
var parser = flags.NewParser(&options, flags.Default)
func main() {
if _, err := parser.Parse(); err != nil {
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp {
os.Exit(0)
} else {
os.Exit(1)
}
}
log.Printf("%#+v", options)
}
That allows you to create a map of options when run like this:
Christophers-MacBook-Pro-2:flags goller$ go run main.go --users link1:link.com --users link2:link2.com
2017/06/23 09:47:11 main.Options{Users:map[string]string{"link1":"link.com", "link2":"link2.com"}}