diff --git a/server/internal/command/command.go b/server/internal/command/command.go index 2c62c718..7b5975e3 100644 --- a/server/internal/command/command.go +++ b/server/internal/command/command.go @@ -28,6 +28,8 @@ func SetupCommand() { var rootCmd = &cobra.Command{Use: path.Base(os.Args[0])} flags := rootCmd.PersistentFlags() + flags.StringP("workdir", "W", "", "Set working directory") + flags.Bool("debug", false, "Debug mode") flags.MarkHidden("debug") viper.BindPFlag("debug", flags.Lookup("debug")) @@ -46,6 +48,11 @@ func SetupCommand() { uuid.EnableRandPool() rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) { + dir, _ := cmd.Flags().GetString("workdir") + if dir != "" && dir != "." { + logrus.Info("Changing directory to " + dir) + os.Chdir(dir) + } if viper.GetBool("debug") { logrus.SetLevel(logrus.TraceLevel) logrus.Debug("Running in debug mode") diff --git a/server/internal/command/serve/engine.go b/server/internal/command/serve/engine.go index d675308a..58771530 100644 --- a/server/internal/command/serve/engine.go +++ b/server/internal/command/serve/engine.go @@ -28,7 +28,7 @@ func createEngine(config *viper.Viper) *gin.Engine { if config.GetBool("cors.enabled") { origins := config.GetStringSlice("cors.origins") - logrus.Info("Enabling cors. Origins: " + strings.Join(origins, ", ")) + logrus.Info("Enabling cors (" + strings.Join(origins, ", ") + ")") engine.Use(cors.New(cors.Config{ AllowOrigins: origins, AllowHeaders: []string{"Origin", "Authorization", "Accept", "Accept-Language", "Content-Type"},