compflag

package
v2.0.1-alpha.10 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MIT Imports: 6 Imported by: 4

Documentation

Overview

Package compflag provides a handful of standard library-compatible flags with bash complition capabilities.

Usage

import "github.com/posener/complete/v2/compflag"

var (
	// Define flags...
	foo = compflag.String("foo", "", "")
)

func main() {
	compflag.Parse("my-program")
	// Main function.
}

Alternatively, the library can just be used with the standard library flag package:

import (
	"flag"
	"github.com/posener/complete/v2/compflag"
)

var (
	// Define flags...
	foo = compflag.String("foo", "", "")
	bar = flag.String("bar", "", "")
)

func main() {
	complete.CommandLine("my-program")
	flag.ParseArgs()
	// Main function.
}

Index

Constants

This section is empty.

Variables

View Source
var CommandLine = (*FlagSet)(flag.CommandLine)

Functions

func Bool

func Bool(name string, value bool, usage string, options ...predict.Option) *bool

func Int

func Int(name string, value int, usage string, options ...predict.Option) *int

func Parse

func Parse(name string)

Parse parses command line arguments. It also performs bash completion when needed.

func String

func String(name string, value string, usage string, options ...predict.Option) *string

Types

type FlagSet

type FlagSet flag.FlagSet

FlagSet is bash completion enabled flag.FlagSet.

func (*FlagSet) Bool

func (fs *FlagSet) Bool(name string, value bool, usage string, options ...predict.Option) *bool

func (*FlagSet) Complete

func (fs *FlagSet) Complete(name string)

Complete performs bash completion if needed.

func (*FlagSet) Int

func (fs *FlagSet) Int(name string, value int, usage string, options ...predict.Option) *int

func (*FlagSet) Parse

func (fs *FlagSet) Parse(args []string) error

Parse parses command line arguments.

func (*FlagSet) String

func (fs *FlagSet) String(name string, value string, usage string, options ...predict.Option) *string

Jump to

Keyboard shortcuts

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