update readme and beautiful help

This commit is contained in:
天元
2020-08-27 13:27:45 +08:00
parent ef0d974c16
commit c23b61b2b2
5 changed files with 93 additions and 55 deletions

113
README.md
View File

@@ -16,25 +16,81 @@ mv bin/vela /usr/local/bin
## Vela commands
### Click the picture to watch the video
```shell script
$ vela
✈️ A Micro App Platform for Kubernetes.
[![POC Video](./resources/vela-help.jpg)](https://oam-budao.oss-cn-beijing.aliyuncs.com/Vela%20First%20PoC.mp4 "POC video")
Usage:
vela [flags]
vela [command]
Available Commands:
Getting Started:
env Manage application environments
delete Delete environment
init <envName> Create environment and switch to it
ls List all environments
switch switch to another environment
version Prints out build version information
Applications:
app Manage applications with ls, show, delete, run
delete <APPLICATION_NAME> Delete Applications
ls List applications with workloads, traits, status and created time
run <APPLICATION_BUNDLE_NAME> [args] Run a bundle of OAM Applications
show <APPLICATION-NAME> get details of your app, including its workload and trait
status <APPLICATION-NAME> get status of an application, including its workload and trait
comp Manage Components
delete <ComponentName> Delete Component From Application
ls List applications with workloads, traits, status and created time
run [args] Init and Run workloads
show <COMPONENT-NAME> get component detail, including arguments of workload and trait
Traits:
rollout <appname> [args] Attach rollout trait to an app
route <appname> [args] Attach route trait to an app
scale <appname> [args] Attach scale trait to an app
Want more? < install more capabilities by `vela cap` >
Others:
cap Capability Management with config, list, add, remove capabilities
add <center>/<name> Add capability into cluster
center <command> Manage Capability Center with config, sync, list
ls [centerName] List all capabilities in center
remove <name> Remove capability from cluster
System:
completion < bash | zsh > Output shell completion code for the specified shell (bash or zsh...
bash Generate the autocompletion script for Vela for the bash shell....
zsh Generate the autocompletion script for Vela for the zsh shell.
T...
dashboard Setup API Server and launch Dashboard
system system management utilities
info show vela client and cluster version
init Install OAM runtime and vela builtin capabilities.
update Refresh and sync definition files from cluster
```
#### env
```
$ vela env init test --namespace test
Create env succeed, current env is test
$ vela env test
NAME NAMESPACE
test test
$ vela env ls
NAME NAMESPACE
default default
test test
NAME CURRENT NAMESPACE
default default
test * test
$ vela env sw default
$ vela env switch default
Switch env succeed, current env is default
$ vela env delete test
@@ -46,7 +102,7 @@ Error: you can't delete current using default
#### workload run
```shell script
$ vela comp run app123 -p 80 --image nginx:1.9.4
$ vela comp run -t deployment app123 -p 80 --image nginx:1.9.4
Creating AppConfig app123
SUCCEED
```
@@ -54,33 +110,16 @@ SUCCEED
#### app
```
$ vela app ls
NAME WORKLOAD TRAITS STATUS CREATED-TIME
app123 ContainerizedWorkload app123-manualscaler-trait False 2020-08-05 20:19:03 +0800 CST
poc08032042 ContainerizedWorkload True 2020-08-03 20:43:02 +0800 CST
poc1039 ContainerizedWorkload poc1039-manualscaler-trait False 2020-08-02 10:39:54 +0800 CST
$ vela app status app123
status: "False"
trait:
- apiVersion: core.oam.dev/v1alpha2
kind: ManualScalerTrait
metadata:
creationTimestamp: null
name: app123-manualscaler-trait
spec:
definitionRef:
name: ""
workload:
apiVersion: core.oam.dev/v1alpha2
kind: ContainerizedWorkload
metadata:
creationTimestamp: null
name: app123
spec:
definitionRef:
name: ""
app123
poc08032042
poc1039
$ vela comp ls
NAME APP WORKLOAD TRAITS STATUS CREATED-TIME
ccc ccc deployment Deployed 2020-08-27 10:56:41 +0800 CST
com1 com1 Deployed 2020-08-26 16:45:50 +0800 CST
com2 com1 Deployed 2020-08-26 16:45:50 +0800 CST
myapp myapp route,scale Deployed 2020-08-19 15:11:17 +0800 CST
$ vela app delete app123
Deleting AppConfig "app123"

View File

@@ -36,11 +36,10 @@ type EnvMeta struct {
const (
TagCommandType = "commandType"
TypeStart = "Getting Started"
TypeApp = "Applications"
TypeWorkloads = "Workloads"
TypeTraits = "Traits"
TypeRelease = "Release"
TypeOthers = "Others"
TypeSystem = "System"
TypeStart = "Getting Started"
TypeApp = "Applications"
TypeTraits = "Traits"
TypeRelease = "Release"
TypeOthers = "Others"
TypeSystem = "System"
)

View File

@@ -6,7 +6,6 @@ import (
"math/rand"
"os"
"runtime"
"strings"
"time"
"github.com/cloud-native-application/rudrx/version"
@@ -68,9 +67,8 @@ func newCommand() *cobra.Command {
cmd.Printf("✈️ A Micro App Platform for Kubernetes.\n\nUsage:\n vela [flags]\n vela [command]\n\nAvailable Commands:\n\n")
PrintHelpByTag(cmd, allCommands, types.TypeStart)
PrintHelpByTag(cmd, allCommands, types.TypeApp)
PrintHelpByTag(cmd, allCommands, types.TypeWorkloads)
PrintHelpByTag(cmd, allCommands, types.TypeTraits)
PrintHelpByTag(cmd, allCommands, types.TypeRelease)
//PrintHelpByTag(cmd, allCommands, types.TypeRelease)
PrintHelpByTag(cmd, allCommands, types.TypeOthers)
PrintHelpByTag(cmd, allCommands, types.TypeSystem)
cmd.Println("Flags:")
@@ -140,16 +138,18 @@ func newCommand() *cobra.Command {
}
func PrintHelpByTag(cmd *cobra.Command, all []*cobra.Command, tag string) {
cmd.Printf(" %s:\n", tag)
cmd.Printf(" %s:\n\n", tag)
table := uitable.New()
for _, c := range all {
useline := strings.TrimPrefix(c.UseLine(), "vela ")
if val, ok := c.Annotations[types.TagCommandType]; ok && val == tag {
table.AddRow(" "+useline, c.Long)
table.AddRow(" "+c.Use, c.Long)
for _, subcmd := range c.Commands() {
table.AddRow(" "+subcmd.Use, " "+subcmd.Long)
}
}
}
cmd.Println(table.String())
if tag == types.TypeWorkloads || tag == types.TypeTraits {
if tag == types.TypeTraits {
if len(table.Rows) > 0 {
cmd.Println()
}

View File

@@ -18,7 +18,7 @@ import (
func CapabilityCommandGroup(c types.Args, ioStream cmdutil.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "cap <command>",
Use: "cap",
Short: "Capability Management",
Long: "Capability Management with config, list, add, remove capabilities",
Annotations: map[string]string{

View File

@@ -29,12 +29,12 @@ func newRunOptions(ioStreams util.IOStreams) *runOptions {
func AddCompCommands(c types.Args, ioStreams util.IOStreams) *cobra.Command {
compCommands := &cobra.Command{
Use: "comp <commands>",
Use: "comp",
DisableFlagsInUseLine: true,
Short: "Manage Components",
Long: "Manage Components",
Annotations: map[string]string{
types.TagCommandType: types.TypeWorkloads,
types.TagCommandType: types.TypeApp,
},
}
compCommands.PersistentFlags().StringP(App, "a", "", "specify application name for component")
@@ -75,7 +75,7 @@ func NewCompRunCommands(c types.Args, ioStreams util.IOStreams) *cobra.Command {
return o.Run(cmd)
},
Annotations: map[string]string{
types.TagCommandType: types.TypeWorkloads,
types.TagCommandType: types.TypeApp,
},
}
runCmd.SetOut(ioStreams.Out)