cmd

package
v0.0.0-...-f3d0bd8 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2018 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

print gathers all tools for formatting output

Index

Constants

View Source
const (
	IpfsFsPath = "IpfsFsPath"
)

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "dt",
	Short: "data together CLI",
	Long:  `command line client for data together`,
}

RootCmd represents the base command when called without any subcommands

Functions

func ErrExit

func ErrExit(err error)

ErrExit writes an error to stdout & exits

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func ExitIfErr

func ExitIfErr(err error)

func GetFilestore

func GetFilestore(online bool) (cafs.Filestore, error)

func GetWd

func GetWd() string

GetWd is a convenience method to get the working directory or bail.

func PrintErr

func PrintErr(err error, params ...interface{})

func PrintInfo

func PrintInfo(msg string, params ...interface{})

func PrintNotYetFinished

func PrintNotYetFinished(cmd *cobra.Command)

func PrintSuccess

func PrintSuccess(msg string, params ...interface{})

func PrintWarning

func PrintWarning(msg string, params ...interface{})

func SetLogger

func SetLogger(logger Logger)

this package implements the LogSetter interface

func SetNoColor

func SetNoColor()

Types

type Logger

type Logger interface {
	Info(...interface{})
	Infof(string, ...interface{})
	Debug(...interface{})
	Debugf(string, ...interface{})
}

Logger interface is to get around the package-level logger anti-pattern https://dave.cheney.net/2017/01/23/the-package-level-logger-anti-pattern I agree in principle with Dave that importing loggers into packages is an anti-pattern, but don't want to pollute custom types with logging details. So, we'll still use a global logging variable, and packages need simply implement the SetLogger interface with anything that accepts a logger. As a default we drop to using fmt-level logging & fmt as a stand-in, defined in this file. consumers of this package should call SetLogger with a chosen logger

Jump to

Keyboard shortcuts

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