Skip to content

ax2/cobra-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

Example

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:

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.

About

A powerful web system for cobra

Resources

License

Stars

Watchers

Forks

Packages

No packages published