mirror of
https://github.com/EnumeratedDev/bpm-utils.git
synced 2026-09-24 14:36:13 +00:00
Improve flag system
This commit is contained in:
@@ -2,11 +2,6 @@ module git.enumerated.dev/bubble-package-manager/bpm-utils/src/bpm-setup
|
||||
|
||||
go 1.23
|
||||
|
||||
require (
|
||||
bpm-utils-shared v1.0.0
|
||||
github.com/spf13/pflag v1.0.10
|
||||
)
|
||||
|
||||
require gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
require github.com/spf13/pflag v1.0.10
|
||||
|
||||
replace bpm-utils-shared => ../bpm-utils-shared
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
+13
-5
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
bpmutilsshared "bpm-utils-shared"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -26,13 +25,12 @@ var git = flag.BoolP("git", "g", true, "Create git repository")
|
||||
|
||||
func main() {
|
||||
// Setup flags and help
|
||||
bpmutilsshared.SetupHelp("bpm-setup <options>", "Sets up files and directories for BPM source package creation")
|
||||
bpmutilsshared.SetupFlags()
|
||||
setupFlagsAndHelp("bpm-setup <options>", "Sets up files and directories for BPM source package creation")
|
||||
|
||||
// Show command help if no directory name is given
|
||||
if *directory == "" {
|
||||
log.Println("Directory flag is required")
|
||||
bpmutilsshared.ShowHelp()
|
||||
log.Println("Error: directory flag is required")
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -182,3 +180,13 @@ func createDirectory() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setupFlagsAndHelp(usage, desc string) {
|
||||
flag.Usage = func() {
|
||||
fmt.Println("Usage: " + usage)
|
||||
fmt.Println("Description: " + desc)
|
||||
fmt.Println("Options:")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user