-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (37 loc) · 923 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
package main
import (
"os"
"log"
"docopt"
"gobundle/gobundle"
)
const Version = "0.1"
const Usage = `
Usage:
gobundle <entry_file> [-o <file>|--output=<file>]
gobundle (-h | --help)
gobundle --version
Options:
<entry_file> Entry file.
-o <file> --output=<file> Output file.
-h --help Show this screen.
--version Show version.`
func main() {
args, _ := docopt.Parse(Usage, nil, true, Version, false)
entryFile := args["<entry_file>"].(string)
outputFile, ok := args["--output"].(string)
if !ok {
outputFile = ""
}
writer := os.Stdout
if len(outputFile) > 0 {
fp, err := os.Create(outputFile)
if err != nil {
log.Fatalln(err)
}
defer fp.Close()
writer = fp
}
bundle := gobundle.Bundle(entryFile)
gobundle.WriteBundle(writer, bundle)
}