flaglists

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 2 Imported by: 0

README

package flaglists

A collection of types that implement the necessary interfaces for flag.Var()

Usage

import "git.thecommune.io/tybrown/go-flaglists"

Example

package main

import (
	"flag"

	"git.thecommune.io/tybrown/go-flaglists"
	"github.com/sirupsen/logrus"
)

var log = logrus.WithFields(logrus.Fields{"app": "example"})

func main() {
	var values flaglists.Strings
	flag.Var(&values, "value", "Values. Specify multiple times for each value.")
	flag.Parse()

	if len(values) == 0 {
		log.Info("You didn't pass any -values flags")
	} else {
		for _, v := range values {
			log.Info("Received value: ", v)
		}
		log.Info("Stringified version of values: ", values.String())
	}
}

Documentation

Overview

A collection of types that implement the necessary interfaces for flag.Var()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Strings

type Strings []string

Strings is a []string that implements the necessary interface for flag.Var()

func (Strings) Contains

func (l Strings) Contains(s string) bool

Contains checks if the given string exists in the flaglist

func (*Strings) Set

func (l *Strings) Set(value string) error

Set adds a value to the Strings

func (Strings) String

func (l Strings) String() string

String returns a stringified representation of the Strings

Jump to

Keyboard shortcuts

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