mirror of
https://github.com/kataras/iris.git
synced 2025-12-19 19:07:06 +00:00
Fix and improve the iris cmd according to this: https://github.com/kataras/iris/issues/506
This commit is contained in:
45
iris/main.go
45
iris/main.go
@@ -1,59 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/iris-contrib/logger"
|
||||
"github.com/kataras/cli"
|
||||
"github.com/kataras/iris"
|
||||
)
|
||||
|
||||
const (
|
||||
// Version of Iris command line tool
|
||||
Version = "0.0.9"
|
||||
)
|
||||
|
||||
var (
|
||||
app *cli.App
|
||||
printer *logger.Logger
|
||||
workingDir string
|
||||
// Name the name of the cmd tool
|
||||
Name = "Iris Command Line Tool"
|
||||
app *cli.App
|
||||
defaultInstallDir string
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
// set the current working dir
|
||||
if d, err := os.Getwd(); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
workingDir = d
|
||||
}
|
||||
|
||||
// init the cli app
|
||||
app = cli.NewApp("iris", "Command line tool for Iris web framework", Version)
|
||||
app = cli.NewApp("iris", "Command line tool for Iris web framework", iris.Version)
|
||||
// version command
|
||||
app.Command(cli.Command("version", "\t prints your iris version").Action(func(cli.Flags) error { app.Printf("%s", iris.Version); return nil }))
|
||||
|
||||
// create command/-/create.go
|
||||
createCmd := cli.Command("create", "create a project to a given directory").
|
||||
Flag("offline", false, "set to true to disable the packages download on each create command").
|
||||
Flag("dir", workingDir, "$GOPATH/src/$dir the directory to install the sample package").
|
||||
Flag("type", "basic", "creates a project based on the -t package. Currently, available types are 'basic' & 'static'").
|
||||
Action(create)
|
||||
|
||||
app.Command(cli.Command("version", "\t prints your iris version").
|
||||
Action(func(cli.Flags) error { app.Printf("%s", app.Version); return nil }))
|
||||
// run command/-/run.go
|
||||
runAndWatchCmd := cli.Command("run", "runs and reload on source code changes, example: iris run main.go").Action(runAndWatch)
|
||||
|
||||
// register the commands
|
||||
app.Command(createCmd)
|
||||
app.Command(runAndWatchCmd)
|
||||
app.Command(buildGetCommand())
|
||||
app.Command(buildRunCommand())
|
||||
|
||||
// init the logger
|
||||
printer = logger.New(logger.DefaultConfig())
|
||||
}
|
||||
|
||||
func main() {
|
||||
// run the application
|
||||
app.Run(func(f cli.Flags) error {
|
||||
app.Run(func(cli.Flags) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user