Package command provide simple API to create modern command-line interface

Package command

Package command provide simple API to create modern command-line interface, mainly for lightweight usage, inspired by cobra

Usage

package main

import (
	"fmt"
	"os"

	"github.com/chenen3/command"
)

func main() {
	// Initial root command
	root := &command.Command{
		Name: "root", // change this to actual project name
		Desc: "example description of root command",
		Do: func(self *command.Command) {
			self.Help()
		},
	}

	// Add sub command
	versionCmd := &command.Command{
		Name: "version",
		Desc: "print version",
		Do: func(_ *command.Command) {
			fmt.Println("version v0.1-beta")
		},
	}
	root.AddCommand(versionCmd)

	// Execute root command
	err := root.Execute()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}

Example output

$ go run main.go
example description of root command

Usage:
  root [flags]
  root [command]

Commands:
  version    	print version

Flags:
  -help
    	help for root

Use "root [command] --help" for more information about a command.
$ go run main.go version
version v0.1-beta
Similar Resources

A modern UNIX ed (line editor) clone written in Go

ed (the awesome UNIX line editor) ed is a clone of the UNIX command-line tool by the same name ed a line editor that was nortorious for being and most

May 29, 2021

Command Line Interface for Terraform Enterprise/Cloud ( tecli )

Command Line Interface for Terraform Enterprise/Cloud ( tecli )

In a world where everything is Terraform, teams use Terraform Cloud API to manage their workloads. TECLI increases teams productivity by facilitating such interaction and by providing easy commands that can be executed on a terminal or on CI/CD systems.

Dec 16, 2022

FireFly Command Line Interface (CLI)

FireFly Command Line Interface (CLI)

FireFly CLI The FireFly CLI can be used to create a local FireFly stacks for offline development of blockchain apps. This allows developers to rapidly

Mar 1, 2022

a command line interface to orbit.love

orbit-cli NAME: orbit-cli - a command line interface to orbit.love USAGE: orbit-cli [global options] command [command options] [arguments...]

May 18, 2021

Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go.

What is Lux? Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go. Lux provides it's users with the abilit

Dec 28, 2022

FireFly Command Line Interface (CLI)

FireFly Command Line Interface (CLI)

FireFly CLI The FireFly CLI can be used to create a local FireFly stacks for offline development of blockchain apps. This allows developers to rapidly

Dec 13, 2022

Command line interface for flomo.

flomo-cli A Golang based command line interface of flomo. 中文说明 Features Type and save to flomo using command line. Editor mode supports, able to use v

Sep 19, 2022

Gofire 🔥 Command Line Interface Generator tool for Go

Gofire 🔥 Command Line Interface Generator tool for Go

Gofire 🔥 : Command Line Interface Generator tool for Go Introduction Gofire is the tool for Go that automatically generates a command line interface

Dec 6, 2022

Command line interface for control iTunes

Command line interface for control iTunes

iTunes CLI Command line interface for control iTunes Description You can control iTunes operations from command line. Equipments macOS Sierra or later

Sep 30, 2022
Related tags
🚀 goprobe is a promising command line tool for inspecting URLs with modern and user-friendly way.

goprobe Build go build -o ./bin/goprobe Example > goprobe https://github.com/gaitr/goprobe > cat links.txt | goprobe > echo "https://github.com/gaitr/

Oct 24, 2021
Sipexer - Modern and flexible SIP (RFC3261) command line tool

sipexer Modern and flexible SIP (RFC3261) command line tool. Overview sipexer is

Jan 1, 2023
kcli: command line interface tool to interact with K8trics API server as well as manage its lifecycle
kcli: command line interface tool to interact with K8trics API server as well as manage its lifecycle

K8trics CLI (kcli) kcli is command line interface tool to interact with K8trics API server as well as manage its lifecycle. kcli can provision and dep

Dec 15, 2021
A command-line interface for the Riak database through its HTTP API
A command-line interface for the Riak database through its HTTP API

Riakg Description Is a development oriented command line tool that enables navigation on buckets, keys and values of a Riak KV data store using it's H

Dec 31, 2022
Inotify-tools is a C library and a set of command-line programs providing a simple interface to inotify.

inotify-tools This is a package of some commandline utilities relating to inotify. The general purpose of this package is to allow inotify's features

Jan 4, 2023
bluemonday-cli is a simple command-line interface to bluemonday

bluemonday-cli bluemonday-cli is a simple command-line interface to bluemonday. We've configured bluemonday for ROVR's specific requirements. It reads

Jan 24, 2022
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.

asciigraph Go package to make lightweight ASCII line graphs ╭┈╯. Installation go get github.com/guptarohit/asciigraph Usage Basic graph package main

Jan 8, 2023
An open-source GitLab command line tool bringing GitLab's cool features to your command line
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Dec 30, 2022
A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

Nov 22, 2021
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Dec 22, 2021