1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 10:10:53 +00:00

Improve bee command lines

Clean and improve some of the command option descriptions
This commit is contained in:
areski 2014-12-18 17:19:34 +01:00
parent f00aeaed36
commit 6b85a2c475
7 changed files with 49 additions and 56 deletions

View File

@ -24,22 +24,23 @@ import (
var cmdApiapp = &Command{ var cmdApiapp = &Command{
// CustomFlags: true, // CustomFlags: true,
UsageLine: "api [appname]", UsageLine: "api [appname]",
Short: "create an api application base on beego framework", Short: "create an API beego application",
Long: ` Long: `
create an api application base on beego framework Create an API beego application.
bee api [appname] [-tables=""] [-driver=mysql] [-conn=root:@tcp(127.0.0.1:3306)/test] bee api [appname] [-tables=""] [-driver=mysql] [-conn=root:@tcp(127.0.0.1:3306)/test]
-tables: a list of table names separated by ',', default is empty, indicating all tables -tables: a list of table names separated by ',' (default is empty, indicating all tables)
-driver: [mysql | postgres | sqlite], the default is mysql -driver: [mysql | postgres | sqlite] (default: mysql)
-conn: the connection string used by the driver, the default is '' -conn: the connection string used by the driver, the default is ''
e.g. for mysql: root:@tcp(127.0.0.1:3306)/test e.g. for mysql: root:@tcp(127.0.0.1:3306)/test
e.g. for postgres: postgres://postgres:postgres@127.0.0.1:5432/postgres e.g. for postgres: postgres://postgres:postgres@127.0.0.1:5432/postgres
if conn is empty will create a example api application. otherwise generate api application based on an existing database.
In the current path, will create a folder named [appname] If 'conn' argument is empty, bee api creates an example API application,
when 'conn' argument is provided, bee api generates an API application based
on the existing database.
In the appname folder has the follow struct: The command 'api' creates a folder named [appname] and inside the folder deploy
the following files/directories structure:
conf conf
app.conf app.conf

10
bale.go
View File

@ -30,13 +30,15 @@ var cmdBale = &Command{
UsageLine: "bale", UsageLine: "bale",
Short: "packs non-Go files to Go source files", Short: "packs non-Go files to Go source files",
Long: ` Long: `
bale packs non-Go files to Go source files and Bale command compress all the static files in to a single binary file.
auto-generate unpack function to main package then run it This is usefull to not have to carry static files including js, css, images
and views when publishing a project.
during the runtime. auto-generate unpack function to main package then run it during the runtime.
This is mainly used for zealots who are requiring 100% Go code.
This is mainly used for zealots who are requiring 100% Go code.`, `,
} }
func init() { func init() {

View File

@ -31,22 +31,22 @@ var cmdMigrate = &Command{
Long: ` Long: `
bee migrate [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] bee migrate [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"]
run all outstanding migrations run all outstanding migrations
-driver: [mysql | postgresql | sqlite], the default is mysql -driver: [mysql | postgresql | sqlite] (default: mysql)
-conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test -conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test
bee migrate rollback [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] bee migrate rollback [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"]
rollback the last migration operation rollback the last migration operation
-driver: [mysql | postgresql | sqlite], the default is mysql -driver: [mysql | postgresql | sqlite] (default: mysql)
-conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test -conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test
bee migrate reset [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] bee migrate reset [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"]
rollback all migrations rollback all migrations
-driver: [mysql | postgresql | sqlite], the default is mysql -driver: [mysql | postgresql | sqlite] (default: mysql)
-conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test -conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test
bee migrate refresh [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] bee migrate refresh [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"]
rollback all migrations and run them all again rollback all migrations and run them all again
-driver: [mysql | postgresql | sqlite], the default is mysql -driver: [mysql | postgresql | sqlite] (default: mysql)
-conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test -conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test
`, `,
} }
@ -56,7 +56,7 @@ var mConn docValue
func init() { func init() {
cmdMigrate.Run = runMigration cmdMigrate.Run = runMigration
cmdMigrate.Flag.Var(&mDriver, "driver", "database driver: mysql, postgresql, etc.") cmdMigrate.Flag.Var(&mDriver, "driver", "database driver: mysql, postgresql, sqlite, etc.")
cmdMigrate.Flag.Var(&mConn, "conn", "connection string used by the driver to connect to a database instance") cmdMigrate.Flag.Var(&mConn, "conn", "connection string used by the driver to connect to a database instance")
} }
@ -376,6 +376,6 @@ CREATE TABLE migrations (
rollback_statements longtext COMMENT 'SQL statment for rolling back migration', rollback_statements longtext COMMENT 'SQL statment for rolling back migration',
status ENUM('update', 'rollback') COMMENT 'update indicates it is a normal migration while rollback means this migration is rolled back', status ENUM('update', 'rollback') COMMENT 'update indicates it is a normal migration while rollback means this migration is rolled back',
PRIMARY KEY (id_migration) PRIMARY KEY (id_migration)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
` `
) )

15
new.go
View File

@ -23,13 +23,12 @@ import (
var cmdNew = &Command{ var cmdNew = &Command{
UsageLine: "new [appname]", UsageLine: "new [appname]",
Short: "create an application base on beego framework", Short: "Create a Beego application",
Long: ` Long: `
create an application base on beego framework, Creates a Beego application for the given app name in the current directory.
which in the current path with folder named [appname]. The command 'new' creates a folder named [appname] and inside the folder deploy
the following files/directories structure:
The [appname] folder has following structure:
|- main.go |- main.go
|- conf |- conf
@ -313,9 +312,9 @@ var indextpl = `<!DOCTYPE html>
</header> </header>
<footer> <footer>
<div class="author"> <div class="author">
Official website: Official website:
<a href="http://{{.Website}}">{{.Website}}</a> / <a href="http://{{.Website}}">{{.Website}}</a> /
Contact me: Contact me:
<a class="email" href="mailto:{{.Email}}">{{.Email}}</a> <a class="email" href="mailto:{{.Email}}">{{.Email}}</a>
</div> </div>
</footer> </footer>

21
pack.go
View File

@ -37,22 +37,23 @@ import (
var cmdPack = &Command{ var cmdPack = &Command{
CustomFlags: true, CustomFlags: true,
UsageLine: "pack", UsageLine: "pack",
Short: "compress an beego project", Short: "Compress a beego project into a single file",
Long: ` Long: `
compress an beego project Pack is used to compress a beego project into a single file.
This eases the deployment by extracting the zip file to a server.
-p app path. default is current path -p app path (default is the current path).
-b build specify platform app. default true -b build specify platform app (default: true).
-ba additional args of go build -ba additional args of go build
-be=[] additional ENV Variables of go build. eg: GOARCH=arm -be=[] additional ENV Variables of go build. eg: GOARCH=arm
-o compressed file output dir. default use current path -o compressed file output dir. default use current path
-f="" format. [ tar.gz / zip ]. default tar.gz -f="" format: tar.gz, zip (default: tar.gz)
-exp="" relpath exclude prefix. default: . -exp="" relpath exclude prefix (default: .).
-exs="" relpath exclude suffix. default: .go:.DS_Store:.tmp -exs="" relpath exclude suffix (default: .go:.DS_Store:.tmp).
all path use : as separator all path use : as separator
-exr=[] file/directory name exclude by Regexp. default: ^. -exr=[] file/directory name exclude by Regexp (default: ^).
-fs=false follow symlink. default false -fs=false follow symlink (default: false).
-ss=false skip symlink. default false -ss=false skip symlink (default: false)
default embed symlink into compressed file default embed symlink into compressed file
-v=false verbose -v=false verbose
`, `,

18
run.go
View File

@ -24,23 +24,11 @@ import (
var cmdRun = &Command{ var cmdRun = &Command{
UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true]", UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true]",
Short: "run the app which can hot compile", Short: "run the app and start a Web server for development",
Long: ` Long: `
start the appname throw exec.Command Run command will supervise the file system of the beego project using inotify,
it will recompile and restart the app after any modifications.
then start a inotify watch for current dir
when the file has changed bee will auto go build and restart the app
file changed
|
check if it's go file
|
yes no
| |
go build do nothing
|
restart app
`, `,
} }

View File

@ -13,13 +13,15 @@ import (
var cmdVersion = &Command{ var cmdVersion = &Command{
UsageLine: "version", UsageLine: "version",
Short: "show the bee & beego version", Short: "show the Bee, Beego and Go version",
Long: ` Long: `
show the bee & beego version show the Bee, Beego and Go version
bee version bee version
bee: 1.1.1 bee :1.2.3
beego: 1.2 beego :1.4.2
Go :go version go1.3.3 linux/amd64
`, `,
} }