forked from laher/someutils
/
ln.go
43 lines (36 loc) · 767 Bytes
/
ln.go
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
42
43
package someutils
import (
"errors"
"github.com/laher/uggo"
)
type LnOptions struct {
IsForce bool
IsSymbolic bool
}
func init() {
Register(Util{
"ln",
Ln})
}
func Ln(call []string) error {
options := LnOptions{}
flagSet := uggo.NewFlagSetDefault("ln", "[options] TARGET LINK_NAME", VERSION)
flagSet.BoolVar(&options.IsSymbolic, "s", false, "Symbolic")
flagSet.BoolVar(&options.IsForce, "f", false, "Force")
e := flagSet.Parse(call[1:])
if e != nil {
println("Error parsing flags")
return e
}
if flagSet.ProcessHelpOrVersion() {
return nil
}
args := flagSet.Args()
if len(args) < 2 {
flagSet.Usage()
return errors.New("Not enough args!")
}
target := args[0]
linkName := args[1]
return makeLink(target, linkName, options)
}