cmd: fix unable to find correct custom config

pull/5940/head
ᴜɴᴋɴᴡᴏɴ 2020-02-22 19:12:31 +08:00
parent 5efbde4fe9
commit d3ecd22dba
No known key found for this signature in database
GPG Key ID: B43718D76E30A238
9 changed files with 24 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -43,7 +43,7 @@ to make automatic initialization process more smoothly`,
stringFlag("password", "", "User password"),
stringFlag("email", "", "User email address"),
boolFlag("admin", "User is an admin"),
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}
@ -55,7 +55,7 @@ to make automatic initialization process more smoothly`,
"All inactivate accounts have been deleted successfully",
),
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}
@ -67,7 +67,7 @@ to make automatic initialization process more smoothly`,
"All repositories archives have been deleted successfully",
),
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}
@ -79,7 +79,7 @@ to make automatic initialization process more smoothly`,
"All repositories archives have been deleted successfully",
),
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}
@ -91,7 +91,7 @@ to make automatic initialization process more smoothly`,
"All repositories have done garbage collection successfully",
),
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}
@ -103,7 +103,7 @@ to make automatic initialization process more smoothly`,
"All public keys have been rewritten successfully",
),
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}
@ -115,7 +115,7 @@ to make automatic initialization process more smoothly`,
"All repositories' pre-receive, update and post-receive hooks have been resynced successfully",
),
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}
@ -127,7 +127,7 @@ to make automatic initialization process more smoothly`,
"All repository records that lost Git files have been reinitialized successfully",
),
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}
)

View File

@ -31,7 +31,7 @@ which can be used for migrating Gogs to another server. The output format is mea
portable among all supported database engines.`,
Action: runBackup,
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
boolFlag("verbose, v", "Show process details"),
stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
stringFlag("target", "./", "Target directory path to save backup archive"),

View File

@ -34,7 +34,7 @@ var (
Usage: "Delegate commands to corresponding Git hooks",
Description: "All sub-commands should only be called by Git",
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
Subcommands: []cli.Command{
subcmdHookPreReceive,

View File

@ -37,7 +37,7 @@ without manually hacking the data files`,
Flags: []cli.Flag{
stringFlag("source", "", "Source directory that stores new locale files"),
stringFlag("target", "", "Target directory that stores old locale files"),
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}
)

View File

@ -32,7 +32,7 @@ If corresponding files or database tables are not presented in the archive, they
be skipped and remain unchanged.`,
Action: runRestore,
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
boolFlag("verbose, v", "Show process details"),
stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
stringFlag("from", "", "Path to backup archive"),

View File

@ -31,7 +31,7 @@ var Serv = cli.Command{
Description: `Serv provide access auth for repositories`,
Action: runServ,
Flags: []cli.Flag{
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}

View File

@ -53,7 +53,7 @@ and it takes care of all the other things for you`,
Action: runWeb,
Flags: []cli.Flag{
stringFlag("port, p", "3000", "Temporary port number to prevent conflict"),
stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
stringFlag("config, c", "", "Custom configuration file path"),
},
}

View File

@ -72,12 +72,13 @@ func Init(customConf string) error {
}
File.NameMapper = ini.SnackCase
customConf, err = filepath.Abs(customConf)
if err != nil {
return errors.Wrap(err, "get absolute path")
}
if customConf == "" {
customConf = filepath.Join(CustomDir(), "conf/app.ini")
customConf = filepath.Join(CustomDir(), "conf", "app.ini")
} else {
customConf, err = filepath.Abs(customConf)
if err != nil {
return errors.Wrap(err, "get absolute path")
}
}
CustomConf = customConf