forked from pksunkara/alpaca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (39 loc) · 957 Bytes
/
main.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
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"github.com/jessevdk/go-flags"
"github.com/pksunkara/alpaca/alpaca"
"os"
)
func main() {
// Options for flags package
var opts struct {
Version bool `short:"v" long:"version" description:"Show version information"`
Format string `short:"f" long:"format" description:"API description format" value-name:"FORMAT"`
Langs alpaca.LanguageOptions `group:"Language Options"`
}
// Build the parser
parser := flags.NewParser(&opts, flags.Default)
// Set usage string
parser.Usage = "[options] <dir>"
// Parse the arguments
args, err := parser.Parse()
if err != nil {
os.Exit(0)
}
// Print version and exit
if opts.Version {
fmt.Println(alpaca.Version)
os.Exit(0)
}
// If no argument is given
if len(args) == 0 {
parser.WriteHelp(os.Stdout)
os.Exit(0)
}
alpaca.LoadLibraryPath(args[0])
if opts.Format != "" {
alpaca.ConvertFormat(opts.Format)
}
alpaca.WriteLibraries(&opts.Langs)
}