cobraui

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 14 Imported by: 0

README ΒΆ

cobra-ui

Corbra-ui is a web system for Cobra, which is a library for creating powerful modern CLI applications.

You can simply add several code lines to add web support to your exist cobra based applications. With cobra-ui, you can run commands via web browser. This is useful, because you maybe want someone else run theses commands, who has no chance to run as CLI.

Give a ⭐️ if this project helped you!

Install

Juat import cobra-ui package into the place where the root command is...

import (
    cobraui "github.com/ax2/cobra-ui"

    ...
)

and then add cobra-ui command to the root command

```go
rootCmd.AddCommand(cobraui.UICmd)

and more, you should change your cobra application, add following line to the command to enable it shown on web:

	urlEncodeCmd = &cobra.Command{
		Use:         "urlencode text",
		Short:       "url encode",
		Args:        cobra.MinimumNArgs(1),
		Annotations: cobraui.Options(),  // Add this line
		Run:         urlencode,
	}

Now, you can start the web application by running the ui command,

./your-cobra-application ui

Code in examples/devx is full cobra application example, here is the screenshot

cobra-ui

🀝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Roadmap

  • Authorization support, use basic auth for seperated commands.
  • File upload.
  • Flags and args type support, default values.
  • Realtime command output display.
  • Configurations.
  • Download results.
  • Scheduled jobs.
  • Run history.
  • Favorite commands.
  • Personalization.

πŸ“ License

Copyright Β© 2022 Alex Xiang.

This project is MIT licensed.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	MAX_CMD_DEEP = 4
)

Variables ΒΆ

View Source
var UICmd = &cobra.Command{
	Use:   "ui",
	Short: "Start the web based UI for cobra based program",
	Run: func(cmd *cobra.Command, args []string) {
		startServer(cmd.Root())
	},
}

Functions ΒΆ

func CmdExecuteAction ΒΆ

func CmdExecuteAction(c *gin.Context)

func CmdInfoAction ΒΆ

func CmdInfoAction(c *gin.Context)

func Options ΒΆ

func Options(options ...string) map[string]string

func ShowCommand ΒΆ

func ShowCommand(c *gin.Context)

Types ΒΆ

type CmdArgInfo ΒΆ

type CmdArgInfo struct {
	Type        string
	Name        string
	Description string
	Default     string
}

type CmdInfo ΒΆ

type CmdInfo struct {
	Name        string
	Description string
	Selected    bool
}

type UiCmdType ΒΆ

type UiCmdType cobra.Command

func (*UiCmdType) UiEnabled ΒΆ

func (c *UiCmdType) UiEnabled() bool

Directories ΒΆ

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL