From f76f5a9ce135b86afd9f1edfc5540a9f6dfb995a Mon Sep 17 00:00:00 2001 From: Michal Zalecki Date: Wed, 2 Dec 2020 08:59:49 +0100 Subject: [PATCH 1/2] Allow to select project to open on start --- cmd/hetty/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/hetty/main.go b/cmd/hetty/main.go index f402cc9..1ea8148 100644 --- a/cmd/hetty/main.go +++ b/cmd/hetty/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "crypto/tls" "flag" "log" @@ -27,6 +28,7 @@ var ( caCertFile string caKeyFile string projPath string + projName string addr string adminPath string ) @@ -35,6 +37,7 @@ func main() { flag.StringVar(&caCertFile, "cert", "~/.hetty/hetty_cert.pem", "CA certificate filepath. Creates a new CA certificate is file doesn't exist") flag.StringVar(&caKeyFile, "key", "~/.hetty/hetty_key.pem", "CA private key filepath. Creates a new CA private key if file doesn't exist") flag.StringVar(&projPath, "projects", "~/.hetty/projects", "Projects directory path") + flag.StringVar(&projName, "project", "", "Project to open on start") flag.StringVar(&addr, "addr", ":8080", "TCP address to listen on, in the form \"host:port\"") flag.StringVar(&adminPath, "adminPath", "", "File path to admin build") flag.Parse() @@ -71,6 +74,10 @@ func main() { } defer projService.Close() + if projName != "" { + projService.Open(context.Background(), projName) + } + scope := scope.New(db, projService) reqLogService := reqlog.NewService(reqlog.Config{ From 2888b4fa679d79da8f1e8c7c345f82961b5d519d Mon Sep 17 00:00:00 2001 From: Michal Zalecki Date: Wed, 2 Dec 2020 09:10:47 +0100 Subject: [PATCH 2/2] Check for error --- cmd/hetty/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/hetty/main.go b/cmd/hetty/main.go index 1ea8148..a8aa94e 100644 --- a/cmd/hetty/main.go +++ b/cmd/hetty/main.go @@ -75,7 +75,10 @@ func main() { defer projService.Close() if projName != "" { - projService.Open(context.Background(), projName) + _, err = projService.Open(context.Background(), projName) + if err != nil { + log.Fatalf("[FATAL] Could not open project: %v", err) + } } scope := scope.New(db, projService)