aboutsummaryrefslogtreecommitdiffsponsor
diff options
context:
space:
mode:
-rw-r--r--cmd/installpkg/main.go11
-rw-r--r--cmd/removepkg/main.go17
2 files changed, 24 insertions, 4 deletions
diff --git a/cmd/installpkg/main.go b/cmd/installpkg/main.go
index 5cc4955..009a2e7 100644
--- a/cmd/installpkg/main.go
+++ b/cmd/installpkg/main.go
@@ -44,6 +44,10 @@ import (
// the previous package's files, and this will catch the few
// corner cases without generating unnecessary writes.
+func usage() {
+ getopt.PrintUsage(os.Stdout)
+}
+
func ParseFlags() *pkgtools.InstallPkgFlags {
flags := pkgtools.DefaultInstallPkgFlags
flags.SetEnvValues()
@@ -56,9 +60,12 @@ func ParseFlags() *pkgtools.InstallPkgFlags {
}
func main() {
+ getopt.SetParameters("package_filename ...")
+ help := getopt.BoolLong("help", 0, "display help")
+
flags := ParseFlags()
- if len(getopt.Args()) == 0 {
- getopt.PrintUsage(os.Stdout)
+ if len(getopt.Args()) == 0 || *help {
+ usage()
return
}
diff --git a/cmd/removepkg/main.go b/cmd/removepkg/main.go
index 5970112..dd21f54 100644
--- a/cmd/removepkg/main.go
+++ b/cmd/removepkg/main.go
@@ -1,24 +1,37 @@
package main
+// TODO: print help when no arguments given
+
import (
"flag"
"fmt"
"os"
"git.server.ky/slackcoder/pkgtools"
+ "github.com/pborman/getopt/v2"
)
+func usage() {
+ getopt.PrintUsage(os.Stdout)
+}
+
func ParseFlags() *pkgtools.RemovePkgFlags {
flags := pkgtools.DefaultRemovePkgFlags
flags.SetEnvValues()
- flag.Parse()
-
+ getopt.Parse()
return &flags
}
func main() {
+ getopt.SetParameters("packagename ...")
+ help := getopt.BoolLong("help", 0, "display help")
+
flags := ParseFlags()
+ if len(getopt.Args()) == 0 || *help {
+ usage()
+ return
+ }
err := pkgtools.RemovePkg(flags, flag.Args()...)
if err != nil {