colored

package
v1.160.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

ColoredCobra allows you to colorize Cobra's text output, making it look better using simple settings to customize individual parts of console output.

Usage example:

1. Insert in cmd/root.go file of your project :

import cc "github.com/ivanpirog/coloredcobra"

2. Put the following code to the beginning of the Execute() function:

cc.Init(&cc.Config{
    RootCmd:    rootCmd,
    Headings:   cc.Bold + cc.Underline,
    Commands:   cc.Yellow + cc.Bold,
    ExecName:   cc.Bold,
    Flags:      cc.Bold,
})

3. Build & execute your code.

Copyright © 2022 Ivan Pirog <ivan.pirog@gmail.com>. Released under the MIT license. Project home: https://github.com/ivanpirog/coloredcobra

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(cfg *Config)

Init patches Cobra's usage template with configuration provided.

Types

type Config

type Config struct {
	RootCmd         *cobra.Command
	NoExtraNewlines bool
	NoBottomNewline bool
}

Config is a settings structure which sets styles for individual parts of Cobra text output.

Note that RootCmd is required.

Example:

c := &cc.Config{
   RootCmd:       rootCmd,
}

Jump to

Keyboard shortcuts

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