-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conf dir #21
Conf dir #21
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,16 +21,38 @@ import ( | |
func main() { | ||
var ifName string | ||
var delay int64 | ||
var configurationBaseDir string | ||
var flagsConfig config.Configuration | ||
|
||
// These two are being used to construct the config path | ||
// XXX if the config has been manually update, it could very well have a devicename that does not align with the directory it's in | ||
flag.StringVar(&configurationBaseDir, "c", "", "Configuration base directory (default to current directory)") | ||
flag.StringVar(&config.Config.DeviceName, "n", "goplay", "Specify device name") | ||
|
||
// These two should override whatever is in the currently store config | ||
flag.StringVar(&flagsConfig.DataDirectory, "d", "", "Data base directory (defaults to configuration directory)") | ||
flag.StringVar(&flagsConfig.PulseSink, "sink", config.Config.PulseSink, "Specify Pulse Audio Sink - Linux only") | ||
|
||
// These are not stored in permanent config | ||
flag.StringVar(&ifName, "i", "eth0", "Specify interface") | ||
flag.Int64Var(&delay, "delay", 0, "Specify hardware delay in ms") | ||
flag.StringVar(&config.Config.PulseSink, "sink", config.Config.PulseSink, "Specify Pulse Audio Sink - Linux only") | ||
flag.Parse() // after declaring flags we need to call it | ||
|
||
config.Config.Load() | ||
// Load the possibly existing config | ||
err := config.Config.Load(configurationBaseDir) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer config.Config.Store() | ||
|
||
// Override config specifics with command-line flags | ||
if flagsConfig.DataDirectory != "" { | ||
config.Config.DataDirectory = flagsConfig.DataDirectory | ||
} | ||
if flagsConfig.PulseSink != "" { | ||
config.Config.PulseSink = flagsConfig.PulseSink | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It start to be a good case to create a new file with all config related code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to give it a go if you are interested and refactor this proper. Question though: are you attached to the idea that the config path must contain the DeviceName? IMHO this is problematic for a number of reasons (filesystem reserved chars vs. mDNS type, duplication of DeviceName in the path, on the command-line, and inside the config file) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not at all attached, the whole focus for me now is to have good sound and audio sync. I am happy with a better configuration/usability if you want to help There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed what matters most is good sound and audio sync :) - keep it coming! Happy to help with the rest (build, packaging, UX) and then just feel free to pick whatever makes sense for you and the project. Thanks again for doing this project - very much appreciated :) |
||
|
||
globals.ErrLog = log.New(os.Stderr, "Error:", log.LstdFlags|log.Lshortfile|log.Lmsgprefix) | ||
|
||
iFace, err := net.InterfaceByName(ifName) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use log.panicf to have a meaningful message