Skip to content

Commit

Permalink
reorganize cli into separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Sep 3, 2024
1 parent beb0eca commit 4dc6090
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
13 changes: 2 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"flag"
"log"

"github.com/mschuchard/vault-raft-backup/aws"
Expand All @@ -10,16 +9,8 @@ import (
)

func main() {
// cli flags for hcl config file path and version
hclConfigPath := flag.String("c", "", "path to hcl file for backup configuration")
version := flag.Bool("version", false, "display current version")
flag.Parse()

// version output
if *version {
log.Print("1.1.2")
return
}
// invoke cli parsing
hclConfigPath := util.Cli()

// construct vault raft backup config
backupConfig, err := util.NewBackupConfig(*hclConfigPath)
Expand Down
23 changes: 23 additions & 0 deletions util/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package util

import (
"flag"
"log"
"os"
)

func Cli() *string {
// cli flags for hcl config file path and version
hclConfigPath := flag.String("c", "", "path to hcl file for backup configuration")
version := flag.Bool("version", false, "display current version")
flag.Parse()

// version output
if *version {
log.Print("1.1.2")
os.Exit(0)
}

// return path to hcl config file
return hclConfigPath
}

0 comments on commit 4dc6090

Please sign in to comment.