Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates #129

Merged
merged 1 commit into from Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -3,8 +3,8 @@ arch:
- ppc64le
language: go
go:
- 1.13
- 1.14.1
- 1.16
- 1.17.5
env:
- GOARCH: amd64
- GOARCH: 386
Expand Down
10 changes: 6 additions & 4 deletions Makefile
@@ -1,9 +1,11 @@
GO = GO111MODULE=on GOFLAGS=-mod=vendor go
GO = go

.PHONY: deps
deps:
$(GO) mod download
$(GO) mod vendor
deps: go.mod

go.mod:
go mod init
go mod tidy

.PHONY: test
test:
Expand Down
4 changes: 4 additions & 0 deletions NOTICE.txt
@@ -0,0 +1,4 @@
Spinner
Copyright (c) 2021 Brian J. Downs
This product is licensed to you under the Apache 2.0 license (the "License"). You may not use this product except in compliance with the Apache 2.0 License.
This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -15,6 +15,9 @@ go get github.com/briandowns/spinner
```

## Available Character Sets

90 Character Sets. Some examples below:

(Numbered by their slice index)

| index | character set | sample gif |
Expand Down Expand Up @@ -151,15 +154,15 @@ You can specify both the background and foreground color, as well as additional
s.Color("red", "bold") // Set the spinner color to a bold red
```

Or to set the background to black, the foreground to a bold red:
To set the background to black, the foreground to a bold red:

```Go
s.Color("bgBlack", "bold", "fgRed")
```

Below is the full color and attribute list:

```
```Go
// default colors
red
black
Expand Down
25 changes: 25 additions & 0 deletions character_sets.go
@@ -1,3 +1,17 @@
// Copyright (c) 2021 Brian J. Downs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package spinner

const (
Expand Down Expand Up @@ -25,6 +39,7 @@ var CharSets = map[int][]string{
15: {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"},
16: {"▉", "▊", "▋", "▌", "▍", "▎", "▏", "▎", "▍", "▌", "▋", "▊", "▉"},
17: {"■", "□", "▪", "▫"},

18: {"←", "↑", "→", "↓"},
19: {"╫", "╪"},
20: {"⇐", "⇖", "⇑", "⇗", "⇒", "⇘", "⇓", "⇙"},
Expand Down Expand Up @@ -86,6 +101,16 @@ var CharSets = map[int][]string{
78: {"⠈⠁", "⠈⠑", "⠈⠱", "⠈⡱", "⢀⡱", "⢄⡱", "⢄⡱", "⢆⡱", "⢎⡱", "⢎⡰", "⢎⡠", "⢎⡀", "⢎⠁", "⠎⠁", "⠊⠁"},
79: {"________", "-_______", "_-______", "__-_____", "___-____", "____-___", "_____-__", "______-_", "_______-", "________", "_______-", "______-_", "_____-__", "____-___", "___-____", "__-_____", "_-______", "-_______", "________"},
80: {"|_______", "_/______", "__-_____", "___\\____", "____|___", "_____/__", "______-_", "_______\\", "_______|", "______\\_", "_____-__", "____/___", "___|____", "__\\_____", "_-______"},
81: {"□", "◱", "◧", "▣", "■"},
82: {"□", "◱", "▨", "▩", "■"},
83: {"░", "▒", "▓", "█"},
84: {"░", "█"},
85: {"⚪", "⚫"},
86: {"◯", "⬤"},
87: {"▱", "▰"},
88: {"➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒", "➓"},
89: {"½", "⅓", "⅔", "¼", "¾", "⅛", "⅜", "⅝", "⅞"},
90: {"↞", "↟", "↠", "↡"},
}

func init() {
Expand Down
5 changes: 4 additions & 1 deletion spinner.go
@@ -1,3 +1,5 @@
// Copyright (c) 2021 Brian J. Downs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -171,7 +173,7 @@ func validColor(c string) bool {

// Spinner struct to hold the provided options.
type Spinner struct {
mu *sync.RWMutex //
mu *sync.RWMutex
Delay time.Duration // Delay is the speed of the indicator
chars []string // chars holds the chosen character set
Prefix string // Prefix is the text preppended to the indicator
Expand Down Expand Up @@ -202,6 +204,7 @@ func New(cs []string, d time.Duration, options ...Option) *Spinner {
for _, option := range options {
option(s)
}

return s
}

Expand Down
2 changes: 2 additions & 0 deletions spinner_test.go
@@ -1,3 +1,5 @@
// Copyright (c) 2021 Brian J. Downs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down