scli

package module
v0.0.0-...-230b801 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: MIT Imports: 8 Imported by: 0

README

SCLI

A simple command line interface with flags and (sub)commands.

License

Copyright 2019 Licenced under the terms of the MIT license (see LICENSES for details)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name    string
	Version string
	Desc    string
	Flags   flag.FlagSet
	Cmds    []*Cmd
	Exec    func(args []string) error

} //struct

App is the root of a scli command line application. It has fields to display when help is called and optional commands and a default function to execute if no commands are run.

func (*App) Run

func (a *App) Run() (err error)

Run is the same as RunWith(os.Args)

func (*App) RunWith

func (a *App) RunWith(args []string) (err error)

RunWith runs the App with the supplied args. That args are first parsed through the flags with the remaining passed to a command or the Exec func. The args are expected to be in the form of ["executable name", "flags and args"...].

func (*App) WriteUsage

func (a *App) WriteUsage(out io.Writer) error

WriteUsage will write the usage to the supplied io.Writer.

type Cmd

type Cmd struct {
	Name string
	Desc string
	Exec func(args []string) error
	Subs []*Cmd

} //struct

Cmd is a command that can be run from an App.

func (*Cmd) Matches

func (c *Cmd) Matches(s string) bool

Matches checks if the command should run based on the supplied string.

func (*Cmd) Run

func (c *Cmd) Run(args []string) error

Run executes the command with the supplied args.

type Command

type Command interface {
	Matches(s string) bool
	Run(args []string) error

} //interface

Command is a representation "subcommands" present on the command line.

Jump to

Keyboard shortcuts

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