From d3313f7bc7eb995d7d900c9bc3718ea7f10fc5b5 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Fri, 29 Aug 2014 15:06:05 +0800 Subject: [PATCH 01/10] bee intro --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 23b3c72..dda7153 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,50 @@ bee [![Build Status](https://drone.io/github.com/beego/bee/status.png)](https://drone.io/github.com/beego/bee/latest) -Bee is a tool for helping develop with beego app framework. +Bee is a command line tool facilitating development with beego framework. ## Requirements -- Go version >= 1.1. \ No newline at end of file +- Go version >= 1.1. + +## Installation + +Begin by installing `bee` using `go get` command. + + go get github.com/beego/bee + +Then you can add `bee` binary to PATH: + + export PATH=$PATH:/bin/bee + +> If you already have `bee` installed, updating `bee` is simple: + + go get -u github.com/beego/bee + +## Basic commands + +Bee provides a variety of commands which can be helpful at various stage of development. The top level commands include: + + new create an application base on beego framework + run run the app which can hot compile + pack compress an beego project + api create an api application base on beego framework + bale packs non-Go files to Go source files + version show the bee & beego version + generate source code generator + migrate run database migrations + +### Shortcuts + +Because you'll likely type these commands over and over, it makes sense to create aliases. + +```bash +# Generator Stuff +alias g:a="bee generate appcode" +alias g:m="bee generate model" +alias g:c="bee generate controller" +alias g:v="bee generate view" +alias g:mig="bee generate migration" +``` + +These can be stored in, for example, your `~/.bash_profile` or `~/.bashrc` files. From 478cbb39b9060ec6d9e82083730d6be5d01112fe Mon Sep 17 00:00:00 2001 From: Zheng Yang Date: Fri, 29 Aug 2014 15:17:22 +0800 Subject: [PATCH 02/10] minor update --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dda7153..7ca78af 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,11 @@ Begin by installing `bee` using `go get` command. go get github.com/beego/bee -Then you can add `bee` binary to PATH: +Then you can add `bee` binary to PATH environment variable in your `~/.bashrc` or `~/.bash_profile` file: - export PATH=$PATH:/bin/bee +```bash +export PATH=$PATH:/bin/bee +``` > If you already have `bee` installed, updating `bee` is simple: @@ -46,7 +48,7 @@ alias g:a="bee generate appcode" alias g:m="bee generate model" alias g:c="bee generate controller" alias g:v="bee generate view" -alias g:mig="bee generate migration" +alias g:mi="bee generate migration" ``` These can be stored in, for example, your `~/.bash_profile` or `~/.bashrc` files. From c33b57b6052d79f1a89a46baf74b0fde3b72c511 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Fri, 29 Aug 2014 15:32:13 +0800 Subject: [PATCH 03/10] added help --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7ca78af..a6b35e0 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,37 @@ Bee provides a variety of commands which can be helpful at various stage of deve generate source code generator migrate run database migrations -### Shortcuts +## bee version -Because you'll likely type these commands over and over, it makes sense to create aliases. +The first command is the easiest: displaying which version of `bee`, `beego` and `go` is installed on your machine: + +```bash +$ bee version +bee :1.2.2 +beego :1.4.0 +Go :go version go1.2.1 linux/amd64 +``` + +## bee new + + +## bee run + +## bee pack + +## bee api + +## bee bale + +## bee migrate + +## bee generate + + + +## Shortcuts + +Because you'll likely type these generator commands over and over, it makes sense to create aliases. ```bash # Generator Stuff @@ -52,3 +80,37 @@ alias g:mi="bee generate migration" ``` These can be stored in, for example, your `~/.bash_profile` or `~/.bashrc` files. + +## Help + +If you happend to forget the usage of a command, you can always find the usage information by `bee help `. + +For instance, to get more information about the `run` command: + +```bash +$ bee help run +usage: bee new [appname] + +create an application base on beego framework, + +which in the current path with folder named [appname]. + +The [appname] folder has following structure: + + |- main.go + |- conf + |- app.conf + |- controllers + |- default.go + |- models + |- routers + |- router.go + |- tests + |- default_test.go + |- static + |- js + |- css + |- img + |- views + index.tpl +``` \ No newline at end of file From 6df71de34bd5563be8eb9f3b5db6e97ae4f63e05 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Fri, 29 Aug 2014 15:34:07 +0800 Subject: [PATCH 04/10] output message --- README.md | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index a6b35e0..2bd18db 100644 --- a/README.md +++ b/README.md @@ -89,28 +89,22 @@ For instance, to get more information about the `run` command: ```bash $ bee help run -usage: bee new [appname] +usage: bee run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] -create an application base on beego framework, +start the appname throw exec.Command -which in the current path with folder named [appname]. +then start a inotify watch for current dir + +when the file has changed bee will auto go build and restart the app -The [appname] folder has following structure: + file changed + | + check if it's go file + | + yes no + | | + go build do nothing + | + restart app - |- main.go - |- conf - |- app.conf - |- controllers - |- default.go - |- models - |- routers - |- router.go - |- tests - |- default_test.go - |- static - |- js - |- css - |- img - |- views - index.tpl ``` \ No newline at end of file From 001326934e9183315835781651b4e451cdbe73a9 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Fri, 29 Aug 2014 15:42:40 +0800 Subject: [PATCH 05/10] added info for 'new' command --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 2bd18db..51e1d40 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,31 @@ Go :go version go1.2.1 linux/amd64 ## bee new +Creating a new beego web application is no big deal, too. + +```bash +$ bee new myapp +[INFO] Creating application... +/home/zheng/gopath/src/bee/myapp/ +/home/zheng/gopath/src/bee/myapp/conf/ +/home/zheng/gopath/src/bee/myapp/controllers/ +/home/zheng/gopath/src/bee/myapp/models/ +/home/zheng/gopath/src/bee/myapp/routers/ +/home/zheng/gopath/src/bee/myapp/tests/ +/home/zheng/gopath/src/bee/myapp/static/ +/home/zheng/gopath/src/bee/myapp/static/js/ +/home/zheng/gopath/src/bee/myapp/static/css/ +/home/zheng/gopath/src/bee/myapp/static/img/ +/home/zheng/gopath/src/bee/myapp/views/ +/home/zheng/gopath/src/bee/myapp/conf/app.conf +/home/zheng/gopath/src/bee/myapp/controllers/default.go +/home/zheng/gopath/src/bee/myapp/views/index.tpl +/home/zheng/gopath/src/bee/myapp/routers/router.go +/home/zheng/gopath/src/bee/myapp/tests/default_test.go +/home/zheng/gopath/src/bee/myapp/main.go +2014/08/29 15:38:59 [SUCC] New application successfully created! +``` + ## bee run From d40a327f066dc9cb392c651fce662827fa24b13c Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Fri, 29 Aug 2014 15:47:21 +0800 Subject: [PATCH 06/10] no big deal --- README.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 51e1d40..b72f19a 100644 --- a/README.md +++ b/README.md @@ -56,24 +56,24 @@ Creating a new beego web application is no big deal, too. ```bash $ bee new myapp [INFO] Creating application... -/home/zheng/gopath/src/bee/myapp/ -/home/zheng/gopath/src/bee/myapp/conf/ -/home/zheng/gopath/src/bee/myapp/controllers/ -/home/zheng/gopath/src/bee/myapp/models/ -/home/zheng/gopath/src/bee/myapp/routers/ -/home/zheng/gopath/src/bee/myapp/tests/ -/home/zheng/gopath/src/bee/myapp/static/ -/home/zheng/gopath/src/bee/myapp/static/js/ -/home/zheng/gopath/src/bee/myapp/static/css/ -/home/zheng/gopath/src/bee/myapp/static/img/ -/home/zheng/gopath/src/bee/myapp/views/ -/home/zheng/gopath/src/bee/myapp/conf/app.conf -/home/zheng/gopath/src/bee/myapp/controllers/default.go -/home/zheng/gopath/src/bee/myapp/views/index.tpl -/home/zheng/gopath/src/bee/myapp/routers/router.go -/home/zheng/gopath/src/bee/myapp/tests/default_test.go -/home/zheng/gopath/src/bee/myapp/main.go -2014/08/29 15:38:59 [SUCC] New application successfully created! +/home/zheng/gopath/src/myapp/ +/home/zheng/gopath/src/myapp/conf/ +/home/zheng/gopath/src/myapp/controllers/ +/home/zheng/gopath/src/myapp/models/ +/home/zheng/gopath/src/myapp/routers/ +/home/zheng/gopath/src/myapp/tests/ +/home/zheng/gopath/src/myapp/static/ +/home/zheng/gopath/src/myapp/static/js/ +/home/zheng/gopath/src/myapp/static/css/ +/home/zheng/gopath/src/myapp/static/img/ +/home/zheng/gopath/src/myapp/views/ +/home/zheng/gopath/src/myapp/conf/app.conf +/home/zheng/gopath/src/myapp/controllers/default.go +/home/zheng/gopath/src/myapp/views/index.tpl +/home/zheng/gopath/src/myapp/routers/router.go +/home/zheng/gopath/src/myapp/tests/default_test.go +/home/zheng/gopath/src/myapp/main.go +2014/08/29 15:45:47 [SUCC] New application successfully created! ``` From db40c4ced217db214a69a33307635f1e4180d0e6 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Fri, 29 Aug 2014 15:55:53 +0800 Subject: [PATCH 07/10] bee run --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b72f19a..e043b40 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,15 @@ $ bee new myapp 2014/08/29 15:45:47 [SUCC] New application successfully created! ``` - ## bee run +To run the application we just created, navigate to the application folder and execute `bee run`. + +```bash +$ cd myapp +$ bee run +``` + ## bee pack ## bee api From 995ad2934a1bd357130fe4aefeb3652a4a0c9f02 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Fri, 29 Aug 2014 16:03:43 +0800 Subject: [PATCH 08/10] skeleton --- README.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/README.md b/README.md index e043b40..8ac8d94 100644 --- a/README.md +++ b/README.md @@ -87,14 +87,87 @@ $ bee run ## bee pack +coming soon ... + ## bee api +coming soon ... + ## bee bale +coming soon ... + ## bee migrate +```bash +usage: bee migrate [Command] + +bee migrate [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] + run all outstanding migrations + -driver: [mysql | postgresql | sqlite], the default is mysql + -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"] + rollback the last migration operation + -driver: [mysql | postgresql | sqlite], the default is mysql + -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"] + rollback all migrations + -driver: [mysql | postgresql | sqlite], the default is mysql + -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"] + rollback all migrations and run them all again + -driver: [mysql | postgresql | sqlite], the default is mysql + -conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test + +``` + ## bee generate +Bee also comes with a souce code generate which speeds up the development. + +```bash +usage: bee generate [Command] + +bee generate scaffold [scaffoldname] [-fields=""] [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] + The generate scaffold command will do a number of things for you. + -fields: a list of table fields. Format: field:type, ... + -driver: [mysql | postgres | sqlite], the default is mysql + -conn: the connection string used by the driver, the default is root:@tcp(127.0.0.1:3306)/test + example: bee generate scaffold post -fields="title:string,body:text" + +bee generate model [modelname] [-fields=""] + generate RESTFul model based on fields + -fields: a list of table fields. Format: field:type, ... + +bee generate controller [controllerfile] + generate RESTFul controllers + +bee generate view [viewpath] + generate CRUD view in viewpath + +bee generate migration [migrationfile] [-fields=""] + generate migration file for making database schema update + -fields: a list of table fields. Format: field:type, ... + +bee generate docs + generate swagger doc file + +bee generate test [routerfile] + generate testcase + +bee generate appcode [-tables=""] [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] [-level=3] + generate appcode based on an existing database + -tables: a list of table names separated by ',', default is empty, indicating all tables + -driver: [mysql | postgres | sqlite], the default is mysql + -conn: the connection string used by the driver. + default for mysql: root:@tcp(127.0.0.1:3306)/test + default for postgres: postgres://postgres:postgres@127.0.0.1:5432/postgres + -level: [1 | 2 | 3], 1 = models; 2 = models,controllers; 3 = models,controllers,router + +``` ## Shortcuts From ece84c644fe858225ea5aff9da69f44cb1cc2b27 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Fri, 29 Aug 2014 16:04:53 +0800 Subject: [PATCH 09/10] skeleton --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ac8d94..4fceaf2 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ bee migrate refresh [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] ## bee generate -Bee also comes with a souce code generate which speeds up the development. +Bee also comes with a souce code generator which speeds up the development. ```bash usage: bee generate [Command] From 9f45b59a99ea3f9c24f72c10d2a6dbfff8a9ca4d Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Fri, 29 Aug 2014 16:08:28 +0800 Subject: [PATCH 10/10] help messages --- README.md | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4fceaf2..63b793a 100644 --- a/README.md +++ b/README.md @@ -87,15 +87,75 @@ $ bee run ## bee pack -coming soon ... +```bash +usage: bee pack + +compress an beego project + +-p app path. default is current path +-b build specify platform app. default true +-ba additional args of go build +-be=[] additional ENV Variables of go build. eg: GOARCH=arm +-o compressed file output dir. default use current path +-f="" format. [ tar.gz / zip ]. default tar.gz +-exp="" relpath exclude prefix. default: . +-exs="" relpath exclude suffix. default: .go:.DS_Store:.tmp + all path use : as separator +-exr=[] file/directory name exclude by Regexp. default: ^. +-fs=false follow symlink. default false +-ss=false skip symlink. default false + default embed symlink into compressed file +-v=false verbose +``` ## bee api -coming soon ... +```bash +usage: bee api [appname] + +create an api application base on beego framework + +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 + -driver: [mysql | postgres | sqlite], the default is mysql + -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 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] + +In the appname folder has the follow struct: + + ├── conf + │ └── app.conf + ├── controllers + │ └── object.go + │ └── user.go + ├── routers + │ └── router.go + ├── tests + │ └── default_test.go + ├── main.go + └── models + └── object.go + └── user.go +``` ## bee bale -coming soon ... +```bash +usage: bee bale + +bale packs non-Go files to Go source files and + +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. +``` ## bee migrate