gopy/main.go

50 lines
823 B
Go
Raw Normal View History

2015-01-30 17:01:15 +00:00
// Copyright 2015 The go-python Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"log"
"os"
2015-07-24 14:16:31 +00:00
"github.com/gonuts/commander"
"github.com/gonuts/flag"
2015-01-30 17:01:15 +00:00
)
const (
defaultPyVersion = "py2"
)
2015-01-30 17:01:15 +00:00
var (
2015-07-24 14:16:31 +00:00
app *commander.Command
2015-01-30 17:01:15 +00:00
)
2015-07-24 14:16:31 +00:00
func init() {
app = &commander.Command{
UsageLine: "gopy",
Subcommands: []*commander.Command{
gopyMakeCmdGen(),
gopyMakeCmdBind(),
},
Flag: *flag.NewFlagSet("gopy", flag.ExitOnError),
}
2015-01-30 17:01:15 +00:00
}
func main() {
2015-07-24 14:16:31 +00:00
err := app.Flag.Parse(os.Args[1:])
2015-01-30 17:01:15 +00:00
if err != nil {
2015-07-24 14:16:31 +00:00
log.Printf("error parsing flags: %v\n", err)
2015-01-30 17:01:15 +00:00
os.Exit(1)
}
2015-07-24 14:16:31 +00:00
args := app.Flag.Args()
err = app.Dispatch(args)
2015-01-30 17:01:15 +00:00
if err != nil {
2015-07-24 14:16:31 +00:00
log.Printf("error dispatching command: %v\n", err)
2015-01-30 17:01:15 +00:00
os.Exit(1)
}
os.Exit(0)
}