:art: Contextual fmt inspired by bootstrap color classes

Overview



Cfmt

Contextual fmt




It provides contextual formatting functions that have nearly identical usage of the fmt package. The ideas were borrowed from bootstrap's contextual color classes.

Installation

go get github.com/mingrammer/cfmt

Usage

package main

import (
    "log"

    "github.com/mingrammer/cfmt"
)

func main() {
    cfmt.Success("User was created successfully")
    cfmt.Infoln("Here are some candidates")
    cfmt.Warningf("%s is not valid integer value\n", "123a")
    log.Fatal(cfmt.Serrorf("Only numeric is allowed, got %s", "123.456a"))
}

cfmt output

Contextual functions

Note: cfmt.Errorf function does not do same things to fmt.Errorf, but to fmt.Printf with red colored text.

  • Success (Green)
    • Fsuccess, Fsuccessf, Fsuccessln
    • Success, Successf, Successln
    • Ssuccess, Ssuccessf, Ssuccessln
  • Info (Cyan)
    • Finfo, Finfof, Finfoln
    • Info, Infof, Infoln
    • Sinfo, Sinfof, Sinfoln
  • Warning (Yellow)
    • Fwarning, Fwarningf, Fwarningln
    • Warning, Warningf, Warningln
    • Swarning, Swarningf, Swarningln
  • Error (Red)
    • Ferror, Ferrorf, Ferrorln
    • Error, Errorf, Errorln
    • Serror, Serrorf, Serrorln

License

MIT

You might also like...
Contextual Content Discovery Tool
Contextual Content Discovery Tool

Kiterunner Introduction For the longest of times, content discovery has been focused on finding files and folders. While this approach is effective fo

Automation Tool to auto generate markdown notes from online classes/talks/presentations.
Automation Tool to auto generate markdown notes from online classes/talks/presentations.

autonotes Automation tool to autocapture screenshots and join them with a supplied .srt or .txt file and output a notes file in markdown. Problem? Wat

Contextual information about your git projects, right on the command-line
Contextual information about your git projects, right on the command-line

gitty gitty is a smart little CLI helper for git projects, that shows you all the relevant issues, pull requests and changes at a quick glance. It cur

An excellent tool for converting json files to structs or classes in any programming language.
An excellent tool for converting json files to structs or classes in any programming language.

Explore Usage » Report Bug · Request Feature Table of Contents About The Project Supported Languages Getting Started Usage Parameters Set Up Your Own

Libruscord - Discord bot that downloads classes for a given day from the schedule in Librus

libruscord Bot który pozwala na pobranie zajęć na dzisiejszy dzień z terminarza

 MPD client inspired by ncmpcpp written in GO with builtin cover art previews.
MPD client inspired by ncmpcpp written in GO with builtin cover art previews.

goMP MPD client inspired by ncmpcpp written in GO demo.mp4 Roadmap Add Functionality to Sort out most played songs Add a config parser Image Previews

Same as fmt.Errorf but with stack trace.

Annotation with stack trace for go1.13 Go 1.13 contains support for error wrapping. Now you can add additional information to an error by wrapping it

A lightweight replacement for the standard fmt package, reduces binary size by roughly 400kb in a hello world

console This is a lightweight replacement for the fmt package, reduces the binary size by roughly 400kb in a hello world program. Please note: This pa

Translate your Go program into multiple languages with similar fmt.Sprintf format syntax.

Loafer-i18n Loafer-i18n is a Go package and a command that helps you translate Go programs into multiple languages. Supports pluralized strings with =

Linter for Go's fmt.Errorf message

wrapmsg wrapmsg is Go code linter. this enforces fmt.Errorf's message when you wrap error. Example // OK 👍🏻 if err := pkg.Cause(); err != nil { re

Package core is a service container that elegantly bootstrap and coordinate twelve-factor apps in Go.

Package core is a service container that elegantly bootstrap and coordinate twelve-factor apps in Go. Background The twelve-factor methodology has pro

Bootstrap a new project from a template.

Go Starter Go-starter allows to bootstrap a new project from a template. It uses Git repositories as templates and is shipped with batch of utilities

Bootstrap curated Kubernetes stacks. Logging, metrics, ingress and more - delivered with gitops.

Gimlet Stack Bootstrap curated Kubernetes stacks. Logging, metrics, ingress and more - delivered with gitops. You can install logging aggregators, met

A simple template using Fiber for me to bootstrap API services quickly.

Fiber Template A simple template using Fiber for me to bootstrap API services quickly. Features Fiber GORM air for hot reloading ... and possibly more

Use this template to bootstrap the creation of a Golang action

Create an Action using Golang Use this template to bootstrap the creation of a G

Decrypts and dumps K3s bootstrap data read from stdin.

k3s-dump-bootstrap Decrypts and dumps K3s bootstrap data read from stdin. Note: token parameter should be just the bare passphrase, not a full K10-f

Generates a simple skeleton directory structure for go/gin/bootstrap web apps

Gin Bootstrap Initializer Generates a simple skeleton directory structure for go/gin/bootstrap web apps Description This package handles building a co

:pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go
:pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go

Region quadtrees in Go Region quadtrees and efficient neighbour finding techniques in Go Go-rquad proposes various implementations of region quadtrees

3D line art engine.
3D line art engine.

ln The 3D Line Art Engine ln is a vector-based 3D renderer written in Go. It is used to produce 2D vector graphics (think SVGs) depicting 3D scenes. T

Comments
  • Use github.com/logrusorgru/aurora instead of github.com/fatih/color

    Use github.com/logrusorgru/aurora instead of github.com/fatih/color

    Fixed https://github.com/mingrammer/cfmt/issues/4

    Passed all the tests.

    $ git status
    ## use-aurora...origin/use-aurora
    $ go test ./...
    ok  	github.com/mingrammer/cfmt	(cached)
    

    Could you review it, please?

    opened by is2ei 7
  • Align ln behaviour with fmt.Println

    Align ln behaviour with fmt.Println

    Example:

    cfmt.Successln("Initialized project at ", "location")
    // Terminal: Initialized project atlocation
    fmt.Println("Initialized project at ", "location")
    // Terminal: Initialized project at location
    
    opened by Wulfheart 0
Releases(v1.1.0)
  • v1.1.0(Dec 5, 2018)

  • v1.0.0(Mar 17, 2018)

    It provides contextual formatting functions that have nearly identical usage of the fmt package. The ideas were borrowed from bootstrap's contextual color classes.

    Source code(tar.gz)
    Source code(zip)
Owner
MinJae Kwon
🐳 Golang & Python. I love computer science, system design, and automate something 💕
MinJae Kwon
Console Text Colors - The non-invasive cross-platform terminal color library does not need to modify the Print method

ctc - Console Text Colors The non-invasive cross-platform terminal color library does not need to modify the Print method Virtual unix-like environmen

null 41 Nov 9, 2022
Change the color of console text.

go-colortext package This is a package to change the color of the text and background in the console, working both under Windows and other systems. Un

Yi Deng 215 Oct 26, 2022
Building powerful interactive prompts in Go, inspired by python-prompt-toolkit.

go-prompt A library for building powerful interactive prompts inspired by python-prompt-toolkit, making it easier to build cross-platform command line

Masashi SHIBATA 4.7k Jan 3, 2023
Go-Generative-Art-A - Generate PNG art from source images! GOLang Generative Art

GO Lang Generative Art Tool A Take source images and generate art utilizing sour

null 5 Nov 21, 2022
A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple.

Maroto A Maroto way to create PDFs. Maroto is inspired in Bootstrap and uses Gofpdf. Fast and simple. Maroto definition: Brazilian expression, means a

Johnathan Fercher 895 Jan 7, 2023
🎨 Terminal color rendering library, support 8/16 colors, 256 colors, RGB color rendering output, support Print/Sprintf methods, compatible with Windows.

?? Terminal color rendering library, support 8/16 colors, 256 colors, RGB color rendering output, support Print/Sprintf methods, compatible with Windows. GO CLI 控制台颜色渲染工具库,支持16色,256色,RGB色彩渲染输出,使用类似于 Print/Sprintf,兼容并支持 Windows 环境的色彩渲染

Gookit 1.2k Dec 30, 2022
A Go package for converting RGB and other color formats/colorspaces into DMC thread colors (DMC color name and floss number)

go-c2dmc A Go package for converting RGB and other color formats/colorspaces into DMC thread colors (DMC color name and floss number). Implemented as

null 6 Jul 25, 2022
COCO (Color Converter) is a color conversion library for Go.

COCO (Color Converter) for Go COCO (Color Converter) is a color conversion library for Go. Heavily inspired by NPM's color-convert. It converts all wa

Hisam Fahri 6 Oct 4, 2022
A pure Go contextual logging library with "batteries included"

Cue Overview Cue implements contextual logging with "batteries included". It has thorough test coverage and supports logging to stdout/stderr, file, s

Bob Ziuchkovski 26 Sep 16, 2019