From 57a58a18a726f4a1a69cf787ef582a682581fdb1 Mon Sep 17 00:00:00 2001 From: EnumDev Date: Tue, 8 Apr 2025 13:43:55 +0300 Subject: [PATCH] Add checks to bpm-setup --- src/bpm-setup/main.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/bpm-setup/main.go b/src/bpm-setup/main.go index a51f32a..a177035 100644 --- a/src/bpm-setup/main.go +++ b/src/bpm-setup/main.go @@ -31,6 +31,9 @@ func main() { os.Exit(1) } + // run checks + runChecks() + // Show summary showSummary() @@ -68,6 +71,20 @@ func help() { fmt.Println(" -g= | Create git repository (Defaults to true)") } +func runChecks() { + if strings.TrimSpace(*directory) == "" { + log.Fatalf("No directory was specified!") + } + + if strings.TrimSpace(*name) == "" { + log.Fatalf("No directory was specified!") + } + + if stat, err := os.Stat(path.Join("/etc/bpm-utils/", *template)); err != nil || stat.IsDir() { + log.Fatalf("%s is not a valid template file!", *template) + } +} + func showSummary() { absPath, err := filepath.Abs(*directory) if err != nil {