mirror of
https://github.com/lwch/natpass.git
synced 2024-04-21 12:41:54 +00:00
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
bindata "github.com/go-bindata/go-bindata/v3"
|
|
)
|
|
|
|
func main() {
|
|
c := bindata.NewConfig()
|
|
|
|
flag.Usage = func() {
|
|
fmt.Printf("Usage: %s [options] <input directories>\n\n", os.Args[0])
|
|
flag.PrintDefaults()
|
|
}
|
|
|
|
flag.BoolVar(&c.Debug, "debug", c.Debug, "Do not embed the assets, but provide the embedding API. Contents will still be loaded from disk.")
|
|
flag.StringVar(&c.Package, "pkg", c.Package, "Package name to use in the generated code.")
|
|
flag.StringVar(&c.Prefix, "prefix", c.Prefix, "Optional path prefix to strip off asset names.")
|
|
flag.StringVar(&c.Output, "o", c.Output, "Optional name of the output file to be generated.")
|
|
flag.Parse()
|
|
|
|
if flag.NArg() == 0 {
|
|
fmt.Fprintf(os.Stderr, "Missing <input dir>\n\n")
|
|
flag.Usage()
|
|
os.Exit(1)
|
|
}
|
|
|
|
c.Input = make([]bindata.InputConfig, flag.NArg())
|
|
for i := range c.Input {
|
|
c.Input[i] = parseInput(flag.Arg(i))
|
|
}
|
|
|
|
err := bindata.Translate(c)
|
|
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "bindata: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func parseInput(path string) bindata.InputConfig {
|
|
if strings.HasSuffix(path, "/...") {
|
|
return bindata.InputConfig{
|
|
Path: filepath.Clean(path[:len(path)-4]),
|
|
Recursive: true,
|
|
}
|
|
}
|
|
return bindata.InputConfig{
|
|
Path: filepath.Clean(path),
|
|
Recursive: false,
|
|
}
|
|
}
|