configcmd

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 7 Imported by: 0

README

configcmd

A config subcommand which handles get/set/delete operations for basic key-value pair configs. Can specifiy that your implementing CLI wants to create multiple configs using the Many field.

Example usage
package main

import (
  "context"
  "flag"
  "os"

  scmd "github.com/google/subcommands"
  "github.com/tlowerison/configcmd"
)

func main() {
  scmd.Register(scmd.HelpCommand(), "")
  scmd.Register(scmd.FlagsCommand(), "")
  scmd.Register(&configcmd.ConfigCmd{Pkg: "cygoose", Many: "project"}, "")

  flag.Parse()
  ctx := context.Background()
  os.Exit(int(scmd.Execute(ctx)))
}
$ cygoose config --help
> config <project> [OPTION] <key> [value]: Manage configurations.
>   -delete
>     	Delete the provided key.
$ cygoose config myproject foo bar
$ cygoose config myproject foo
> bar

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigCmd

type ConfigCmd struct {
	// Name of your CLI
	Pkg string
	// If there are multiple configs managed by this tool, set Many to be the name
	// of the parameter over those configs (e.g. Many = "project" or Many = "repo")
	Many string
	// contains filtered or unexported fields
}

func (*ConfigCmd) Delete added in v1.0.0

func (c *ConfigCmd) Delete(config string, key string) error

func (*ConfigCmd) Execute

func (c *ConfigCmd) Execute(_ context.Context, fs *flag.FlagSet, _ ...interface{}) scmd.ExitStatus

func (*ConfigCmd) Get added in v1.0.0

func (c *ConfigCmd) Get(config string, key string) (*string, error)

func (*ConfigCmd) Name

func (c *ConfigCmd) Name() string

func (*ConfigCmd) Set added in v1.0.0

func (c *ConfigCmd) Set(config string, key string, value string) error

func (*ConfigCmd) SetFlags

func (c *ConfigCmd) SetFlags(fs *flag.FlagSet)

func (*ConfigCmd) Synopsis

func (*ConfigCmd) Synopsis() string

func (*ConfigCmd) Usage

func (c *ConfigCmd) Usage() string

Jump to

Keyboard shortcuts

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