Skip to content

Commit

Permalink
Initial commit for bunt
Browse files Browse the repository at this point in the history
Add basic Travis setup.

Add initial set of Go source files based on github.com/homeport/gonvenience.
  • Loading branch information
HeavyWombat committed Jun 17, 2019
0 parents commit a134c24
Show file tree
Hide file tree
Showing 18 changed files with 1,845 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
language: go
go:
- 1.12.x

install:
- curl --silent --location https://goo.gl/g1CpPX | bash -s v1.0.7

script:
- export GO111MODULE=on
- go mod download
- go mod verify
- ginkgo -r -nodes 4 -randomizeAllSpecs -randomizeSuites -race -trace
- staticcheck ./...
- golint ./...
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 gonvenience

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# bunt

[![License](https://img.shields.io/github/license/gonvenience/bunt.svg)](https://github.com/gonvenience/bunt/blob/master/LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/gonvenience/bunt)](https://goreportcard.com/report/github.com/gonvenience/bunt)
[![Build Status](https://travis-ci.org/gonvenience/bunt.svg?branch=master)](https://travis-ci.org/gonvenience/bunt)
[![GoDoc](https://godoc.org/github.com/gonvenience/bunt/pkg?status.svg)](https://godoc.org/github.com/gonvenience/bunt/pkg)
[![Release](https://img.shields.io/github/release/gonvenience/bunt.svg)](https://github.com/gonvenience/bunt/releases/latest)

Golang package for creating true color output in terminals
56 changes: 56 additions & 0 deletions bunt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package bunt

import (
"github.com/gonvenience/term"
)

// ColorSetting defines the coloring setting to be used
var ColorSetting = AUTO

// TrueColorSetting defines the true color usage setting to be used
var TrueColorSetting = AUTO

// SwitchState is the type to cover different preferences/settings like:
// on, off, or auto
type SwitchState int

// Supported setting states
const (
OFF = SwitchState(-1)
AUTO = SwitchState(0)
ON = SwitchState(+1)
)

// UseColors return whether colors are used or not based on the configured color
// setting or terminal capabilities
func UseColors() bool {
return (ColorSetting == ON) ||
(ColorSetting == AUTO && term.IsTerminal() && !term.IsDumbTerminal())
}

// UseTrueColor returns whether true color colors should be used or not based on
// the configured true color usage setting or terminal capabilities
func UseTrueColor() bool {
return (TrueColorSetting == ON) ||
(TrueColorSetting == AUTO && term.IsTrueColor())
}
33 changes: 33 additions & 0 deletions bunt_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package bunt_test

import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func TestBunt(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "bunt suite")
}
Loading

0 comments on commit a134c24

Please sign in to comment.