aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorzeripath2019-05-14 16:20:35 +0100
committertechknowlogick2019-05-14 11:20:35 -0400
commite55c874dd2a6162a374a9fac46c55db57bd17c5f (patch)
tree0af648181cfc9c59aededfe0b56de21e79baf1dc /main.go
parent488d34691ad79bae13320f3e831a7ff46c245a89 (diff)
Add work path CLI option (#6922)
Makes it possible to set the work path as a CLI option instead of relying on environment variables which are somewhat opaque
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/main.go b/main.go
index 102450f90..4d94d00ab 100644
--- a/main.go
+++ b/main.go
@@ -68,7 +68,7 @@ arguments - which can alternatively be run by running the subcommand web.`
// Now adjust these commands to add our global configuration options
// First calculate the default paths and set the AppHelpTemplates in this context
- setting.SetCustomPathAndConf("", "")
+ setting.SetCustomPathAndConf("", "", "")
setAppHelpTemplates()
// default configuration flags
@@ -84,6 +84,11 @@ arguments - which can alternatively be run by running the subcommand web.`
Usage: "Custom configuration file path",
},
cli.VersionFlag,
+ cli.StringFlag{
+ Name: "work-path, w",
+ Value: setting.AppWorkPath,
+ Usage: "Set the gitea working path",
+ },
}
// Set the default to be equivalent to cmdWeb and add the default flags
@@ -114,10 +119,11 @@ func setFlagsAndBeforeOnSubcommands(command *cli.Command, defaultFlags []cli.Fla
func establishCustomPath(ctx *cli.Context) error {
var providedCustom string
var providedConf string
+ var providedWorkPath string
currentCtx := ctx
for {
- if len(providedCustom) != 0 && len(providedConf) != 0 {
+ if len(providedCustom) != 0 && len(providedConf) != 0 && len(providedWorkPath) != 0 {
break
}
if currentCtx == nil {
@@ -129,10 +135,13 @@ func establishCustomPath(ctx *cli.Context) error {
if currentCtx.IsSet("config") && len(providedConf) == 0 {
providedConf = currentCtx.String("config")
}
+ if currentCtx.IsSet("work-path") && len(providedWorkPath) == 0 {
+ providedWorkPath = currentCtx.String("work-path")
+ }
currentCtx = currentCtx.Parent()
}
- setting.SetCustomPathAndConf(providedCustom, providedConf)
+ setting.SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath)
setAppHelpTemplates()