helper

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Overview

Copyright 2019-2020 vChain, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const DetachedFlag = "detached"
View Source
const DetachedShortFlag = "d"
View Source
const LinuxManPath = "/usr/share/man/man1/"

Variables

View Source
var Blue = "\033[34m"
View Source
var Cyan = "\033[36m"
View Source
var Green = "\033[32m"
View Source
var Purple = "\033[35m"
View Source
var Red = "\033[31m"
View Source
var Reset = "\033[0m"
View Source
var White = "\033[37m"
View Source
var Yellow = "\033[33m"

Functions

func Detached

func Detached()

Detached launch command in background

func PrintTable

func PrintTable(cols []string, nbRows int, getRow func(int) []string)

func PrintfColor added in v0.6.1

func PrintfColor(color string, format string, args ...interface{})

func QuitToStdErr

func QuitToStdErr(msg interface{})

QuitToStdErr prints an error on stderr and closes

func QuitWithUserError

func QuitWithUserError(err error)

QuitWithUserError ...

func ReadFromTerminalYN

func ReadFromTerminalYN(def string) (selected string, err error)

ReadFromTerminalYN read terminal user input from a Yes No dialog. It returns y and n only with an explicit Yy or Nn input. If no input is submitted it returns default value. If the input is different from the expected one empty string is returned.

func ResolvePath

func ResolvePath(origPath string, parse bool) (finalPath string, err error)

ResolvePath

func UsageSprintf

func UsageSprintf(usages map[string][]string) string

Types

type Options

type Options struct {
	CfgFn string
}

Options cmd options

func (*Options) InitConfig

func (o *Options) InitConfig(name string)

InitConfig initializes config

type PasswordReader

type PasswordReader interface {
	Read(string) ([]byte, error)
}
var DefaultPasswordReader PasswordReader = new(stdinPasswordReader)

type RequiredArgs

type RequiredArgs struct {
	Cmd    string
	Usage  string
	Usages map[string][]string
}

func (*RequiredArgs) Require

func (ra *RequiredArgs) Require(
	args []string,
	argPos int,
	argName string,
	invalidArgName string,
	validValues map[string]struct{},
	action string,
) (string, error)

Jump to

Keyboard shortcuts

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