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!
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
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
The default ip port is 8189, you can access it via web browser by http://localhost:8189
Code in examples/devx is a full cobra application example. To run it, just clone the whole project and run:
go run ./examples/devx ui
Make sure that you are in go module mode. Here is the screenshot:
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
- 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.
Copyright © 2022 Alex Xiang.
This project is MIT licensed.