mirror of
https://github.com/kubevela/kubevela.git
synced 2026-04-22 10:37:04 +00:00
clean up vela cli help info to be app focused
This commit is contained in:
@@ -35,10 +35,10 @@ type EnvMeta struct {
|
||||
const (
|
||||
TagCommandType = "commandType"
|
||||
|
||||
TypeStart = "Getting Started"
|
||||
TypeApp = "Applications"
|
||||
TypeTraits = "Traits"
|
||||
TypeRelease = "Release"
|
||||
TypeOthers = "Others"
|
||||
TypeSystem = "System"
|
||||
TypeStart = "Getting Started"
|
||||
TypeApp = "Managing Applications"
|
||||
TypeCap = "Managing Capabilities"
|
||||
TypeSystem = "System"
|
||||
|
||||
TypeTraits = "Traits"
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ func CapabilityCommandGroup(c types.Args, ioStream cmdutil.IOStreams) *cobra.Com
|
||||
Short: "Capability Management",
|
||||
Long: "Capability Management with config, list, add, remove capabilities",
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeOthers,
|
||||
types.TagCommandType: types.TypeCap,
|
||||
},
|
||||
}
|
||||
cmd.AddCommand(
|
||||
@@ -39,9 +39,6 @@ func NewCenterCommand(c types.Args, ioStream cmdutil.IOStreams) *cobra.Command {
|
||||
Use: "center <command>",
|
||||
Short: "Manage Capability Center",
|
||||
Long: "Manage Capability Center with config, sync, list",
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeOthers,
|
||||
},
|
||||
}
|
||||
cmd.AddCommand(
|
||||
NewCapCenterConfigCommand(ioStream),
|
||||
@@ -72,9 +69,6 @@ func NewCapCenterConfigCommand(ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
ioStreams.Infof("Successfully configured capability center %s and sync from remote\n", capName)
|
||||
return nil
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeOthers,
|
||||
},
|
||||
}
|
||||
cmd.PersistentFlags().StringP("token", "t", "", "Github Repo token")
|
||||
return cmd
|
||||
@@ -105,9 +99,6 @@ func NewCapInstallCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Comm
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeOthers,
|
||||
},
|
||||
}
|
||||
cmd.PersistentFlags().StringP("token", "t", "", "Github Repo token")
|
||||
return cmd
|
||||
@@ -137,9 +128,6 @@ func NewCapUninstallCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Co
|
||||
}
|
||||
return oam.RemoveCapability(newClient, name, ioStreams)
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeOthers,
|
||||
},
|
||||
}
|
||||
cmd.PersistentFlags().StringP("token", "t", "", "Github Repo token")
|
||||
return cmd
|
||||
@@ -162,9 +150,6 @@ func NewCapCenterSyncCommand(ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
ioStreams.Info("sync finished")
|
||||
return nil
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeOthers,
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
@@ -193,9 +178,6 @@ func NewCapListCommand(ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
ioStreams.Info(table.String())
|
||||
return nil
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeOthers,
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
@@ -209,9 +191,6 @@ func NewCapCenterListCommand(ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return ListCapCenters(args, ioStreams)
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeOthers,
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
@@ -225,9 +204,6 @@ func NewCapCenterRemoveCommand(ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return RemoveCapCenter(args, ioStreams)
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeOthers,
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -29,9 +29,8 @@ func NewCommand() *cobra.Command {
|
||||
cmd.Printf("✈️ The Extensible Application Platform Based on Kubernetes and Open Application Model (OAM).\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.TypeTraits)
|
||||
PrintHelpByTag(cmd, allCommands, types.TypeCap)
|
||||
PrintHelpByTag(cmd, allCommands, types.TypeSystem)
|
||||
PrintHelpByTag(cmd, allCommands, types.TypeOthers)
|
||||
cmd.Println("Flags:")
|
||||
cmd.Println(" -h, --help help for vela")
|
||||
cmd.Println()
|
||||
@@ -62,10 +61,6 @@ func NewCommand() *cobra.Command {
|
||||
cmds.AddCommand(
|
||||
// Getting Start
|
||||
NewInstallCommand(commandArgs, fake.ChartSource, ioStream),
|
||||
NewEnvCommand(commandArgs, ioStream),
|
||||
NewConfigCommand(commandArgs, ioStream),
|
||||
NewVersionCommand(),
|
||||
NewInitCommand(commandArgs, ioStream),
|
||||
NewUpCommand(commandArgs, ioStream),
|
||||
|
||||
// Apps
|
||||
@@ -73,27 +68,27 @@ func NewCommand() *cobra.Command {
|
||||
NewDeleteCommand(commandArgs, ioStream),
|
||||
NewAppShowCommand(ioStream),
|
||||
NewAppStatusCommand(commandArgs, ioStream),
|
||||
|
||||
// Workloads
|
||||
AddCompCommands(commandArgs, ioStream),
|
||||
|
||||
// Capability Systems
|
||||
CapabilityCommandGroup(commandArgs, ioStream),
|
||||
|
||||
// System
|
||||
SystemCommandGroup(commandArgs, ioStream),
|
||||
NewCompletionCommand(),
|
||||
|
||||
NewTraitsCommand(commandArgs, ioStream),
|
||||
NewWorkloadsCommand(commandArgs, ioStream),
|
||||
|
||||
NewDashboardCommand(commandArgs, ioStream, fake.FrontendSource),
|
||||
|
||||
NewExecCommand(commandArgs, ioStream),
|
||||
NewPortForwardCommand(commandArgs, ioStream),
|
||||
NewLogsCommand(commandArgs, ioStream),
|
||||
NewEnvCommand(commandArgs, ioStream),
|
||||
NewConfigCommand(commandArgs, ioStream),
|
||||
|
||||
// Capabilities
|
||||
CapabilityCommandGroup(commandArgs, ioStream),
|
||||
NewTemplateCommand(commandArgs, ioStream),
|
||||
NewTraitsCommand(commandArgs, ioStream),
|
||||
NewWorkloadsCommand(commandArgs, ioStream),
|
||||
|
||||
// Helper
|
||||
SystemCommandGroup(commandArgs, ioStream),
|
||||
NewDashboardCommand(commandArgs, ioStream, fake.FrontendSource),
|
||||
NewCompletionCommand(),
|
||||
NewVersionCommand(),
|
||||
|
||||
NewInitCommand(commandArgs, ioStream),
|
||||
|
||||
AddCompCommands(commandArgs, ioStream),
|
||||
)
|
||||
|
||||
// Traits
|
||||
@@ -116,18 +111,9 @@ func PrintHelpByTag(cmd *cobra.Command, all []*cobra.Command, tag string) {
|
||||
for _, c := range all {
|
||||
if val, ok := c.Annotations[types.TagCommandType]; ok && val == tag {
|
||||
table.AddRow(" "+c.Use, c.Long)
|
||||
for _, subcmd := range c.Commands() {
|
||||
table.AddRow(" "+subcmd.Use, " "+subcmd.Long)
|
||||
}
|
||||
}
|
||||
}
|
||||
cmd.Println(table.String())
|
||||
if tag == types.TypeTraits {
|
||||
if len(table.Rows) > 0 {
|
||||
cmd.Println()
|
||||
}
|
||||
cmd.Println(" Want more? < install more capabilities by `vela cap` >")
|
||||
}
|
||||
cmd.Println()
|
||||
}
|
||||
|
||||
@@ -146,7 +132,7 @@ GolangVersion: %v
|
||||
runtime.Version())
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeStart,
|
||||
types.TagCommandType: types.TypeSystem,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ func AddCompCommands(c types.Args, ioStreams util.IOStreams) *cobra.Command {
|
||||
DisableFlagsInUseLine: true,
|
||||
Short: "Manage services",
|
||||
Long: "Manage services",
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeApp,
|
||||
},
|
||||
}
|
||||
compCommands.PersistentFlags().StringP(App, "a", "", "specify the name of application containing the services")
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ func NewConfigCommand(args types.Args, io cmdutil.IOStreams) *cobra.Command {
|
||||
Short: "Manage application configurations",
|
||||
Long: "Manage application configurations under given env",
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeStart,
|
||||
types.TagCommandType: types.TypeApp,
|
||||
},
|
||||
}
|
||||
cmd.SetOut(io.Out)
|
||||
|
||||
@@ -22,7 +22,7 @@ func NewEnvCommand(c types.Args, ioStream cmdutil.IOStreams) *cobra.Command {
|
||||
Short: "Manage application environments",
|
||||
Long: "Manage application environments",
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeStart,
|
||||
types.TagCommandType: types.TypeApp,
|
||||
},
|
||||
}
|
||||
cmd.SetOut(ioStream.Out)
|
||||
|
||||
@@ -42,10 +42,7 @@ func NewInitCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
DisableFlagsInUseLine: true,
|
||||
Short: "Init an OAM Application",
|
||||
Long: "Init an OAM Application by one command",
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeStart,
|
||||
},
|
||||
Example: "vela init",
|
||||
Example: "vela init",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
newClient, err := client.New(c.Config, client.Options{Scheme: c.Schema})
|
||||
if err != nil {
|
||||
|
||||
@@ -15,7 +15,7 @@ func NewTemplateCommand(c types.Args, ioStream cmdutil.IOStreams) *cobra.Command
|
||||
Short: "Manage templates",
|
||||
Long: "Manage templates",
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeSystem,
|
||||
types.TagCommandType: types.TypeCap,
|
||||
},
|
||||
}
|
||||
cmd.SetOut(ioStream.Out)
|
||||
|
||||
@@ -40,6 +40,7 @@ func AddTraitCommands(parentCmd *cobra.Command, c types.Args, ioStreams cmdutil.
|
||||
|
||||
var name = tmp.Name
|
||||
pluginCmd := &cobra.Command{
|
||||
Hidden: true,
|
||||
Use: name + " <appname> [args]",
|
||||
DisableFlagsInUseLine: true,
|
||||
Short: "Attach " + name + " trait to an app",
|
||||
@@ -70,9 +71,6 @@ func AddTraitCommands(parentCmd *cobra.Command, c types.Args, ioStreams cmdutil.
|
||||
}
|
||||
return o.Run(ctx, cmd, ioStreams)
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeTraits,
|
||||
},
|
||||
}
|
||||
pluginCmd.SetOut(ioStreams.Out)
|
||||
for _, v := range tmp.Parameters {
|
||||
|
||||
@@ -22,9 +22,6 @@ func NewTraitsCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Command
|
||||
Short: "List traits",
|
||||
Long: "List traits",
|
||||
Example: `vela traits`,
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeTraits,
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if syncCluster {
|
||||
if err := RefreshDefinitions(ctx, c, ioStreams, true); err != nil {
|
||||
@@ -33,6 +30,9 @@ func NewTraitsCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Command
|
||||
}
|
||||
return printTraitList(&workloadName, ioStreams)
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeCap,
|
||||
},
|
||||
}
|
||||
|
||||
cmd.SetOut(ioStreams.Out)
|
||||
|
||||
@@ -20,9 +20,6 @@ func NewWorkloadsCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Comma
|
||||
Short: "List workloads",
|
||||
Long: "List workloads",
|
||||
Example: `vela workloads`,
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeApp,
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if syncCluster {
|
||||
if err := RefreshDefinitions(ctx, c, ioStreams, true); err != nil {
|
||||
@@ -35,6 +32,9 @@ func NewWorkloadsCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Comma
|
||||
}
|
||||
return printWorkloadList(workloads, ioStreams)
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeCap,
|
||||
},
|
||||
}
|
||||
cmd.SetOut(ioStreams.Out)
|
||||
cmd.Flags().BoolVarP(&syncCluster, "sync", "s", true, "Synchronize capabilities from cluster into local")
|
||||
|
||||
Reference in New Issue
Block a user