libclimate

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2019 License: BSD-3-Clause Imports: 3 Imported by: 1

README

libCLImate.Go

Command-Line Interface boilerplate mini-framework, for Go

Introduction

libCLImate is a Command-Line Interface boilerplate mini-framework, which encapsulates the common aspects of Command-Line Interface boilerplate. The first libCLImate was a C/C++ library. There have been several implementations in other languages. libCLImate.Go is the Go version.

Table of Contents

  1. Introduction
  2. Installation
  3. Components
  4. Examples
  5. Project Information

Introduction

T.B.C.

Installation


import libclimate "github.com/synesissoftware/libCLImate.Go"

Components

T.B.C.

Examples

Examples are provided in the examples directory, along with a markdown description for each. A detailed list TOC of them is provided in EXAMPLES.md.

Project Information

Where to get help

GitHub Page

Contribution guidelines

Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/libCLImate.Go.

Dependencies

libCLImate.Go depends on:

License

libCLImate.Go is released under the 3-clause BSD license. See LICENSE for details.

Documentation

Index

Constants

View Source
const (
	VersionMajor int16 = 0
	VersionMinor int16 = 2
	VersionPatch int16 = 0
	Version      int64 = (int64(VersionMajor) << 48) + (int64(VersionMinor) << 32) + (int64(VersionPatch) << 16)

	VersionRevision int16 = VersionPatch
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AliasFlag

type AliasFlag int

Type of flags passed to the libclimate.AddAlias(), libclimate.AddFlag(), and libclimate.AddOption() methods

type Climate

type Climate struct {
	Aliases    []*clasp.Alias
	ParseFlags clasp.ParseFlag
	Version    interface{}
	InfoLines  []string
	// contains filtered or unexported fields
}

Structure representing a CLI parsing context, obtained from libclimate.Init()

func Init

func Init(initFn InitFunc, args ...interface{}) (climate *Climate, err error)

Initialises a Climate instance, according to the given function (which may not be nil) and arguments

func (*Climate) AddAlias

func (cl *Climate) AddAlias(alias clasp.Alias, flags ...AliasFlag)

Adds a (copy of the) alias to the Climate instance

func (*Climate) AddFlag

func (cl *Climate) AddFlag(flag clasp.Alias, flags ...AliasFlag)

Adds a (copy of the) flag to the Climate instance

func (*Climate) AddFlagFunc added in v0.2.0

func (cl *Climate) AddFlagFunc(flag clasp.Alias, flagFn FlagFunc, flags ...AliasFlag)

Adds a (copy of the) flag to the Climate instance

func (*Climate) AddOption

func (cl *Climate) AddOption(option clasp.Alias, flags ...AliasFlag)

Adds a (copy of the) option to the Climate instance

func (*Climate) AddOptionFunc added in v0.2.0

func (cl *Climate) AddOptionFunc(option clasp.Alias, optionFn OptionFunc, flags ...AliasFlag)

Adds a (copy of the) option to the Climate instance

func (Climate) Parse

func (cl Climate) Parse(argv []string, args ...interface{}) (result Result, err error)

Parses a command line, obtaining a Result instance representing the arguments received by the process

func (Climate) ParseAndVerify

func (cl Climate) ParseAndVerify(argv []string, args ...interface{}) (result Result, err error)

Parses via Parse() and verifies via Verify()

Panics, rather than returns, if the ParseFlag_PanicOnFailure flag is specified

type FlagFunc added in v0.2.0

type FlagFunc func()

type InitFlag

type InitFlag int

Type of flags passed to the libclimate.Init() method

const (
	InitFlag_None           InitFlag = 1 << iota
	InitFlag_PanicOnFailure InitFlag = 1 << iota
	InitFlag_NoHelpFlag     InitFlag = 1 << iota
	InitFlag_NoVersionFlag  InitFlag = 1 << iota
)

type InitFunc

type InitFunc func(cl *Climate) error

Callback function for specification of Climate via DSL

type OptionFunc added in v0.2.0

type OptionFunc func(option *clasp.Argument, alias *clasp.Alias)

type ParseFlag

type ParseFlag int

Type of flags passed to the libclimate.Parse() method

const (
	ParseFlag_None            ParseFlag = 1 << iota
	ParseFlag_PanicOnFailure  ParseFlag = 1 << iota
	ParseFlag_DontCheckUnused ParseFlag = 1 << iota
)

type Result

type Result struct {
	Flags       []*clasp.Argument
	Options     []*clasp.Argument
	Values      []*clasp.Argument
	ProgramName string
	Argv        []string
	// contains filtered or unexported fields
}

Structure representing CLI results, obtained from Climate.Parse()

func (Result) FlagIsSpecified

func (result Result) FlagIsSpecified(id interface{}) bool

Determines if the given flag is specified

func (Result) LookupFlag added in v0.2.0

func (result Result) LookupFlag(id interface{}) (*clasp.Argument, bool)

Looks for a flag with the given id - name, or the alias instance - and returns it and the value true if found; if not, returns nil and false

func (Result) LookupOption

func (result Result) LookupOption(id interface{}) (*clasp.Argument, bool)

Looks for an option with the given id - name, or the alias instance - and returns it and the value true if found; if not, returns nil and false

func (Result) Verify

func (result Result) Verify(args ...interface{})

Verifies that all given arguments received are recognised according to the specified flags and options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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