aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-09-25 10:27:49 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-09-25 10:27:49 +0200
commitd0ed765be72f80034fa530ba037e488c35abdd9e (patch)
treed9138f978d9521bd7f5fb5ec53b37a99abb59159 /main.go
parent5b246ec86bc3eee768da2347f031b349d1e1553d (diff)
downloadguichet-d0ed765be72f80034fa530ba037e488c35abdd9e.tar.gz
guichet-d0ed765be72f80034fa530ba037e488c35abdd9e.zip
add a cli feature
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/main.go b/main.go
index 8bfb2f8..c809d25 100644
--- a/main.go
+++ b/main.go
@@ -58,7 +58,8 @@ type ConfigFile struct {
S3Bucket string `json:"s3_bucket"`
}
-var configFlag = flag.String("config", "./config.json", "Configuration file path")
+var fsServer = flag.NewFlagSet("server", flag.ContinueOnError)
+var configFlag = fsServer.String("config", "./config.json", "Configuration file path")
var config *ConfigFile
@@ -114,8 +115,25 @@ func getTemplate(name string) *template.Template {
}
func main() {
- flag.Parse()
+ if len(os.Args) < 2 {
+ server(os.Args[1:])
+ return
+ }
+
+ switch os.Args[1] {
+ case "cli":
+ cliMain(os.Args[2:])
+ case "server":
+ server(os.Args[2:])
+ default:
+ log.Println("Usage: guichet [server|cli] --help")
+ os.Exit(1)
+ }
+}
+func server(args []string) {
+ log.Println("Starting Guichet Server")
+ fsServer.Parse(args)
config_file := readConfig()
config = &config_file