mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
fix config flag
Former-commit-id: 65a11b9443bda4265bf1fd364152bc73b6f9c1bd [formerly 305a3ac513356904f617a7f676af0a24f985d402] [formerly 1e28fe6c8425f10b0bf0d095906cc3d7e7a37bb9 [formerly 2334bb601d
]]
Former-commit-id: aca1773aca8a57a73c635990a4d41fba6e665736 [formerly 3e9b1d5cfff424d8b3d3c28687c885b77ab16587]
Former-commit-id: badcc38a9615287bc232a0aa3fb70310d16afe3c
This commit is contained in:
parent
c5fbb47147
commit
efe36312ec
@ -35,7 +35,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVarP(&config, "config", "c", "", "JSON configuration file")
|
||||
flag.StringVarP(&config, "config", "c", "", "Configuration file")
|
||||
flag.IntVarP(&port, "port", "p", 0, "HTTP Port (default is random)")
|
||||
flag.StringVarP(&addr, "address", "a", "", "Address to listen to (default is all of them)")
|
||||
flag.StringVarP(&database, "database", "d", "./filemanager.db", "Database file")
|
||||
@ -81,7 +81,16 @@ func main() {
|
||||
|
||||
// Add a configuration file if set.
|
||||
if config != "" {
|
||||
viper.SetConfigName(strings.TrimSuffix(config, filepath.Ext(config)))
|
||||
ext := filepath.Ext(config)
|
||||
dir := filepath.Dir(config)
|
||||
config = strings.TrimSuffix(config, ext)
|
||||
|
||||
if dir != "" {
|
||||
viper.AddConfigPath(dir)
|
||||
config = strings.TrimPrefix(config, dir)
|
||||
}
|
||||
|
||||
viper.SetConfigName(config)
|
||||
}
|
||||
|
||||
// Read configuration from a file if exists.
|
||||
|
Loading…
Reference in New Issue
Block a user