compflag

package
v2.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2019 License: MIT Imports: 6 Imported by: 5 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 ...Option) *bool

func Int

func Int(name string, value int, usage string, options ...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 ...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 ...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 ...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 ...Option) *string

type Option

type Option func(*options)

Flag options.

func OptCheck

func OptCheck() Option

OptCheck enforces the valid values on the predicted flag.

func OptValues

func OptValues(values ...string) Option

OptValues allows to set a desired set of valid values for the flag.

Jump to

Keyboard shortcuts

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