aboutsummaryrefslogtreecommitdiffsponsor
path: root/cmd/removepkg/main.go
blob: dd21f54ee3695098d285fb0a55eb9e0b8a1088a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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()

	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 {
		fmt.Println(err)
		os.Exit(-1)
	}
}