aboutsummaryrefslogtreecommitdiff
path: root/config/init.go
diff options
context:
space:
mode:
authorJulien Dessaux2020-01-30 17:44:42 +0100
committerJulien Dessaux2020-01-30 17:44:42 +0100
commitbea8e5aba8fc84dcb0c980c3948ed6d78719dded (patch)
treef84f2722b98f4c2996b64ce24ac322c9709617ed /config/init.go
parentDocument where C structures for state file header and job entry come from (diff)
downloadbareos-zabbix-check-bea8e5aba8fc84dcb0c980c3948ed6d78719dded.tar.gz
bareos-zabbix-check-bea8e5aba8fc84dcb0c980c3948ed6d78719dded.tar.bz2
bareos-zabbix-check-bea8e5aba8fc84dcb0c980c3948ed6d78719dded.zip
Big rafactoring : code split in several modules and some other best practices
Diffstat (limited to '')
-rw-r--r--config/init.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/config/init.go b/config/init.go
new file mode 100644
index 0000000..f737fb3
--- /dev/null
+++ b/config/init.go
@@ -0,0 +1,16 @@
+package config
+
+import "flag"
+
+// Init initialises a program config from the command line flags
+func (c *Config) Init() {
+ flag.BoolVar(&c.verbose, "v", false, "Activates verbose debugging output, defaults to false.")
+ flag.BoolVar(&c.quiet, "q", false, "Suppress all output, suitable to force a silent update of the spool file.")
+ flag.StringVar(&c.stateFile, "f", "", "Force the state file to use, defaults to "+bareosStateFile+" if it exists else "+baculaStateFile+".")
+ flag.StringVar(&c.workDir, "w", "", "Force the work directory to use, defaults to "+bareosWorkDir+" if it exists else "+baculaWorkDir+".")
+
+ // command line arguments parsing
+ flag.Parse()
+ c.checkWorkDir()
+ c.checkStateFile()
+}