Documentation
¶
Index ¶
- Constants
- Variables
- func AskBool(cmd *cobra.Command, flagName string, args *[]string, opts ...survey.AskOpt) (bool, error)
- func AskCommand(cmd *cobra.Command, def *cobra.Command, opts ...survey.AskOpt) (*cobra.Command, error)
- func AskFilterString(cmd *cobra.Command, flagName string, filterString *string, ...)
- func AskID(cmd *cobra.Command, flagName string, id *string, ...)
- func AskLDAPDataInterchangeFormat(requests *ldif.LDIF, editor string) (bool, error)
- func AskMultiline(cmd *cobra.Command, flagName string, args *[]string, opts ...survey.AskOpt) (bool, error)
- func AskString(cmd *cobra.Command, flagName string, args *[]string, password bool, def string, ...) (bool, error)
- func AskStrings(cmd *cobra.Command, flagName string, options, def []string, args *[]string, ...) (bool, error)
- func Flush(results attributes.Maps, requests *ldif.LDIF, format string, out io.Writer) error
- func GetFieldsForBind(bindParameters *auth.BindParameters, dialOptions *auth.DialOptions) logrus.Fields
- func GetFieldsForSearch(searchArguments *client.SearchArguments) logrus.Fields
- func Is256ColorSupported() bool
- func IsColorEnabled() bool
- func IsTerminal(f *os.File) bool
- func IsTrueColorSupported() bool
- func ListSupportedFormats(quote bool) (list []string)
- func PrintColors(fn func(string, ...any) string, format string, a ...any) string
- func PrintlnAndExit(code int, format string, a ...any)
- func SniffFormat(filename, format string) string
- func Stderr() *os.File
- func Stdin() *os.File
- func Stdout() *os.File
- func TerminalSize(f *os.File) (int, int, error)
- type Fields
Constants ¶
const ( CSV = "csv" // CSV format, "," being used as delimiter DEFAULT = "default" // Colorful YAML output LDIF = "ldif" // LDAP Data Interchange Format YAML = "yaml" // YAML )
Variables ¶
var Logger = func() *logrus.Logger { l := logrus.New() l.SetLevel(logrus.WarnLevel) l.SetOutput(Stdout()) l.SetFormatter(&logrus.JSONFormatter{ DisableHTMLEscape: true, PrettyPrint: true, }) supererrors.RegisterCallback(func(err error) { l.SetOutput(Stderr()) if l.Level >= logrus.DebugLevel { err = tracerr.Wrap(err) var frames []string for _, frame := range err.(tracerr.Error).StackTrace() { switch ctx := frame.String(); { case strings.Contains(ctx, "supererrors.Except"), strings.Contains(ctx, "runtime.main()"), strings.Contains(ctx, "runtime.goexit()"): continue default: frames = append(frames, frame.String()) } } l.WithField("stack", frames).Fatalln(err) } l.SetFormatter(&logrus.TextFormatter{ ForceColors: IsColorEnabled(), DisableTimestamp: true, DisableLevelTruncation: true, }) l.Fatalln(err) }) return l }()
App logger (default format JSON)
Functions ¶
func AskBool ¶
func AskBool(cmd *cobra.Command, flagName string, args *[]string, opts ...survey.AskOpt) (bool, error)
Ask to provide a boolean value for given flag, while offering the option to deny answer (skip)
func AskCommand ¶
func AskCommand(cmd *cobra.Command, def *cobra.Command, opts ...survey.AskOpt) (*cobra.Command, error)
Ask to select a sub-command while providing a default sub-command
func AskFilterString ¶ added in v1.0.9
func AskFilterString(cmd *cobra.Command, flagName string, filterString *string, searchArguments *client.SearchArguments)
AskFilterString asks for a filter string (LDAP syntax according to RFC 4515)
func AskID ¶ added in v1.0.9
func AskID(cmd *cobra.Command, flagName string, id *string, searchArguments *client.SearchArguments)
AskID asks for an ID (CN, DN, GUID, SAN, UPN, Name or DisplayName)
func AskLDAPDataInterchangeFormat ¶
Ask to modify an object in LDAP Interchange Data Format
func AskMultiline ¶
func AskMultiline(cmd *cobra.Command, flagName string, args *[]string, opts ...survey.AskOpt) (bool, error)
Ask to provide answers for given flag in multiline text mode (each option is separated by a new line)
func AskString ¶
func AskString(cmd *cobra.Command, flagName string, args *[]string, password bool, def string, opts ...survey.AskOpt) (bool, error)
Ask a string value for given flag, while offering a default value. If default value is not provided, the default value of the flag will be used. Password mode (sensitive input mode) is supported
func AskStrings ¶
func AskStrings(cmd *cobra.Command, flagName string, options, def []string, args *[]string, opts ...survey.AskOpt) (bool, error)
Ask to select one or many option from many fro given flag, default options may be provided. If just one default option is being provided, a selection of only one option is foreseen, otherwise multiple selection is possible.
func Flush ¶ added in v1.0.2
Encode results into given format. Writer is supposed to be either stdout or a file. Per default, colorful YAML format takes precedences and is being emitted to stdout
func GetFieldsForBind ¶
func GetFieldsForBind(bindParameters *auth.BindParameters, dialOptions *auth.DialOptions) logrus.Fields
Produce log fields describing a bind request
func GetFieldsForSearch ¶
func GetFieldsForSearch(searchArguments *client.SearchArguments) logrus.Fields
Produce log fields describing a search request
func Is256ColorSupported ¶
func Is256ColorSupported() bool
Check if current terminal supports ANSI 256-bit color codes. Env variables TERM and COLORTERM are considered
func IsColorEnabled ¶
func IsColorEnabled() bool
Check if current terminal has colors enabled. Env variables CLICOLOR_FORCE, NO_COLOR and CLICOLOR are being considered
func IsTerminal ¶
Check if given terminal descriptor is a terminal or just a pipe
func IsTrueColorSupported ¶
func IsTrueColorSupported() bool
Check fif terminal supports true color mode. Env variables TERM and COLORTERM are evaluated
func ListSupportedFormats ¶
List supported formats
func PrintColors ¶ added in v1.0.4
Print colorized text only if terminal supports ANSI color codes
func PrintlnAndExit ¶
Print to Stdout and exit
func SniffFormat ¶
Detect expected format from file extension