battlegrip

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 14 Imported by: 0

README

Welcome to battlegrip

Battlegrip is a simple companion library to add a little help to your user experience when using Cobra for Go CLI interactions.

In a nutshell, it streamlines the creation of complex multi-flag commands in a simple web form based UI.

When incorporated into your Go CLI the library, once commanded, will perform the following;

  • launch a basic local web server,
  • launch your default browser, navigating to the server,

All CLI commands will be displayed, along with ech commands flags in a smooth form based web page. From there you can create your terminal commands in a clean web form + copy paste feature set.

Features

  • Easy 1 line setup
  • Clean meta driven web page
  • Simple form based style command builder

Install

Grab the lib,

go get github.com/ryanande/battlegrip

Import the library into your root command module,

import (
    "github.com/ryanande/battlegrip"

    ...
)

Where you register your commands, simply register the battlegrip command,

rootCmd.AddCommand(battlegrip.UICmd) // battlegrip setup

Now, you can initiate the library just like any other command in your CLI with the ui command,

./myassembly ui

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2021 Ryan Anderson.

This project is MIT licensed.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UICmd = &cobra.Command{
	Use:   "ui",
	Short: "Launch a web based UI tool that uses the CLI",
	Run: func(cmd *cobra.Command, args []string) {
		err := Serve(cmd.Root())
		if err != nil {
			log.Fatal(err)
		}
	},
}

UICmd is the UI command for running the web server.

Functions

func Serve

func Serve(cmd *cobra.Command) error

Serve starts up and runs the http server.

Types

type ApplicationDetails

type ApplicationDetails struct {
	AssemblyName string
	Command      CommandDetail
}

ApplicationDetails is the primary return object.

type CommandDetail

type CommandDetail struct {
	Name             string             `json:"name"`
	Use              string             `json:"use"`
	NameAndAliases   string             `json:"nameandaliases"`
	Aliases          []string           `json:"aliases"`
	Root             string             `json:"root"`
	ShortDescription string             `json:"short"`
	LongDescription  string             `json:"long"`
	Examples         string             `json:"examples"`
	Hidden           bool               `json:"hidden"`
	IsAvailable      bool               `json:"isavailable"`
	HasParent        bool               `json:"hasparent"`
	ParentName       string             `json:"parentname"`
	ParentUse        string             `json:"parentuse"`
	Options          OptionDescriptions `json:"options"`
	Commands         []CommandDetail    `json:"commands"`
}

CommandDetail structure contains parent level commands meta data.

func GetCommandDetails

func GetCommandDetails(cmd *cobra.Command) (*CommandDetail, error)

GetCommandDetails gathers all details about a command.

type OptionDescription

type OptionDescription struct {
	Name        string      `json:"name"`
	Default     interface{} `json:"default"`
	Description string      `json:"description"`
	Hidden      bool        `json:"hidden"`
	Section     string      `json:"section"`
	Type        string      `json:"type"`
	Values      string      `json:"values,omitempty"`
}

OptionDescription contains a properties that describe a commandline option.

type OptionDescriptions

type OptionDescriptions []OptionDescription

OptionDescriptions contains the descriptions for all commandline options of a command.

Jump to

Keyboard shortcuts

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