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("password", "", "User password"),
stringFlag("email", "", "User email address"), stringFlag("email", "", "User email address"),
boolFlag("admin", "User is an admin"), 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", "All inactivate accounts have been deleted successfully",
), ),
Flags: []cli.Flag{ 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", "All repositories archives have been deleted successfully",
), ),
Flags: []cli.Flag{ 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", "All repositories archives have been deleted successfully",
), ),
Flags: []cli.Flag{ 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", "All repositories have done garbage collection successfully",
), ),
Flags: []cli.Flag{ 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", "All public keys have been rewritten successfully",
), ),
Flags: []cli.Flag{ 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", "All repositories' pre-receive, update and post-receive hooks have been resynced successfully",
), ),
Flags: []cli.Flag{ 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", "All repository records that lost Git files have been reinitialized successfully",
), ),
Flags: []cli.Flag{ 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.`, portable among all supported database engines.`,
Action: runBackup, Action: runBackup,
Flags: []cli.Flag{ 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"), boolFlag("verbose, v", "Show process details"),
stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"), stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
stringFlag("target", "./", "Target directory path to save backup archive"), stringFlag("target", "./", "Target directory path to save backup archive"),

View File

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

View File

@ -37,7 +37,7 @@ without manually hacking the data files`,
Flags: []cli.Flag{ Flags: []cli.Flag{
stringFlag("source", "", "Source directory that stores new locale files"), stringFlag("source", "", "Source directory that stores new locale files"),
stringFlag("target", "", "Target directory that stores old 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.`, be skipped and remain unchanged.`,
Action: runRestore, Action: runRestore,
Flags: []cli.Flag{ 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"), boolFlag("verbose, v", "Show process details"),
stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"), stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
stringFlag("from", "", "Path to backup archive"), stringFlag("from", "", "Path to backup archive"),

View File

@ -31,7 +31,7 @@ var Serv = cli.Command{
Description: `Serv provide access auth for repositories`, Description: `Serv provide access auth for repositories`,
Action: runServ, Action: runServ,
Flags: []cli.Flag{ 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, Action: runWeb,
Flags: []cli.Flag{ Flags: []cli.Flag{
stringFlag("port, p", "3000", "Temporary port number to prevent conflict"), 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 File.NameMapper = ini.SnackCase
if customConf == "" {
customConf = filepath.Join(CustomDir(), "conf", "app.ini")
} else {
customConf, err = filepath.Abs(customConf) customConf, err = filepath.Abs(customConf)
if err != nil { if err != nil {
return errors.Wrap(err, "get absolute path") return errors.Wrap(err, "get absolute path")
} }
if customConf == "" {
customConf = filepath.Join(CustomDir(), "conf/app.ini")
} }
CustomConf = customConf CustomConf = customConf