flagx

package
v0.0.0-...-810cf82 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Package flagx contains a helper type for parsing CAS keys from command line arguments.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyParam

type KeyParam struct {
	// contains filtered or unexported fields
}

KeyParam is a wrapper for cas.Key that is compatible with the flag.Value interface, without compromising the immutability promise of Key.

Example
package main

import (
	"flag"
	"fmt"

	"bazil.org/bazil/cas/flagx"
)

func main() {
	var kp flagx.KeyParam
	var fl flag.FlagSet

	fl.Var(&kp, "key", "blah blah")
	fl.Parse([]string{"-key=095920158295e252b3cb4728713a987875d210eca00d5b69e89e1d2e2e473153ec3de87ada31787b0d5080cdb0f7dcf15ea1f03cec5fef76df027bcc7d57b337"})
	k := kp.Key()
	fmt.Println(k)

}
Output:

095920158295e252b3cb4728713a987875d210eca00d5b69e89e1d2e2e473153ec3de87ada31787b0d5080cdb0f7dcf15ea1f03cec5fef76df027bcc7d57b337

func (*KeyParam) Key

func (kp *KeyParam) Key() cas.Key

Key returns a copy of the current value of the KeyParam.

As usual with cas.Key, the returned value is promised to be immutable.

func (*KeyParam) Set

func (kp *KeyParam) Set(s string) error

Set updates the contents of the key based on the given hex-encoded string.

See flag.Value.Set.

func (KeyParam) String

func (kp KeyParam) String() string

String returns a hex representation of the key.

See flag.Value.String and cas.Key.String.

Jump to

Keyboard shortcuts

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