Giter VIP home page Giter VIP logo

vfmt's Introduction

vfmt

Golang控制台UI库(基于 https://github.com/i582/cfmt 做的修改,主要修复了结构体输出样式失效、并行输出样式失效问题)

USAGE

import "github.com/vua/vfmt"
 //有内容用样式
   output := "Console Output"
   style := "red"
   vfmt.Printf("[vfmt] @[%s::%s]\n", output, style)
   vfmt.Println("[vfmt] @[Console Output::red]")

   //有内容无样式 (四者等价)
   vfmt.Println("[vfmt] @[Console Output::]")
   vfmt.Println("[vfmt] @[Console Output]")
   vfmt.Println("[vfmt] Console Output")
   fmt.Println("[vfmt] Console Output")

   //有样式无内容 (五者等价)
   vfmt.Println("[vfmt] @[::red]")
   vfmt.Println("[vfmt] @[::]")
   vfmt.Println("[vfmt] @[]")
   vfmt.Println("[vfmt]")
   fmt.Println("[vfmt]")

   //结构体输出
   /*
   	type user struct {
   		  id   int
   		  name string
   		  age  int
   	}
   */
   u := user{1, "vua", 18}
   vfmt.Printf("[vfmt] @[%T,%v::#00ff00|bg#ff0000|bold]\n", u, u)

   //叠加样式
   vfmt.Println("[vfmt] @[Console Output::green|bgRed|bold]")

   //16进制颜色
   vfmt.Println("[vfmt] @[Console Output::#00ff00|bg#ff0000|bold]")

   //自定义样式 
   //创建样式:超链接
   vfmt.RegisterStyle("url", "blue|underline")
   vfmt.Println("[vfmt] @[https://www.github.com::url]")

   //嵌套测试 (惰性匹配)
   vfmt.Println("[vfmt] @[@[Console Output::yellow]::red]")

   //并行测试 (惰性匹配)
   vfmt.Println("[vfmt] @[Console Output::yellow]@[Console Output::#cc0ffe]")

Result

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.