mirror of https://gitee.com/namelin2022/ollama
committed by
GitHub
8 changed files with 1325 additions and 14 deletions
@ -0,0 +1,21 @@ |
|||
MIT License |
|||
|
|||
Copyright (c) 2017 Zack |
|||
|
|||
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. |
|||
@ -0,0 +1,121 @@ |
|||
# progressbar |
|||
|
|||
[](https://github.com/schollz/progressbar/actions/workflows/ci.yml) |
|||
[](https://goreportcard.com/report/github.com/schollz/progressbar) |
|||
[](https://gocover.io/github.com/schollz/progressbar) |
|||
[](https://godoc.org/github.com/schollz/progressbar/v3) |
|||
|
|||
A very simple thread-safe progress bar which should work on every OS without problems. I needed a progressbar for [croc](https://github.com/schollz/croc) and everything I tried had problems, so I made another one. In order to be OS agnostic I do not plan to support [multi-line outputs](https://github.com/schollz/progressbar/issues/6). |
|||
|
|||
|
|||
## Install |
|||
|
|||
``` |
|||
go get -u github.com/schollz/progressbar/v3 |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
### Basic usage |
|||
|
|||
```golang |
|||
bar := progressbar.Default(100) |
|||
for i := 0; i < 100; i++ { |
|||
bar.Add(1) |
|||
time.Sleep(40 * time.Millisecond) |
|||
} |
|||
``` |
|||
|
|||
which looks like: |
|||
|
|||
 |
|||
|
|||
|
|||
### I/O operations |
|||
|
|||
The `progressbar` implements an `io.Writer` so it can automatically detect the number of bytes written to a stream, so you can use it as a progressbar for an `io.Reader`. |
|||
|
|||
```golang |
|||
req, _ := http.NewRequest("GET", "https://dl.google.com/go/go1.14.2.src.tar.gz", nil) |
|||
resp, _ := http.DefaultClient.Do(req) |
|||
defer resp.Body.Close() |
|||
|
|||
f, _ := os.OpenFile("go1.14.2.src.tar.gz", os.O_CREATE|os.O_WRONLY, 0644) |
|||
defer f.Close() |
|||
|
|||
bar := progressbar.DefaultBytes( |
|||
resp.ContentLength, |
|||
"downloading", |
|||
) |
|||
io.Copy(io.MultiWriter(f, bar), resp.Body) |
|||
``` |
|||
|
|||
which looks like: |
|||
|
|||
 |
|||
|
|||
|
|||
### Progress bar with unknown length |
|||
|
|||
A progressbar with unknown length is a spinner. Any bar with -1 length will automatically convert it to a spinner with a customizable spinner type. For example, the above code can be run and set the `resp.ContentLength` to `-1`. |
|||
|
|||
which looks like: |
|||
|
|||
 |
|||
|
|||
|
|||
### Customization |
|||
|
|||
There is a lot of customization that you can do - change the writer, the color, the width, description, theme, etc. See [all the options](https://pkg.go.dev/github.com/schollz/progressbar/v3?tab=doc#Option). |
|||
|
|||
```golang |
|||
bar := progressbar.NewOptions(1000, |
|||
progressbar.OptionSetWriter(ansi.NewAnsiStdout()), |
|||
progressbar.OptionEnableColorCodes(true), |
|||
progressbar.OptionShowBytes(true), |
|||
progressbar.OptionSetWidth(15), |
|||
progressbar.OptionSetDescription("[cyan][1/3][reset] Writing moshable file..."), |
|||
progressbar.OptionSetTheme(progressbar.Theme{ |
|||
Saucer: "[green]=[reset]", |
|||
SaucerHead: "[green]>[reset]", |
|||
SaucerPadding: " ", |
|||
BarStart: "[", |
|||
BarEnd: "]", |
|||
})) |
|||
for i := 0; i < 1000; i++ { |
|||
bar.Add(1) |
|||
time.Sleep(5 * time.Millisecond) |
|||
} |
|||
``` |
|||
|
|||
which looks like: |
|||
|
|||
 |
|||
|
|||
|
|||
## Contributing |
|||
|
|||
Pull requests are welcome. Feel free to... |
|||
|
|||
- Revise documentation |
|||
- Add new features |
|||
- Fix bugs |
|||
- Suggest improvements |
|||
|
|||
## Thanks |
|||
|
|||
Thanks [@Dynom](https://github.com/dynom) for massive improvements in version 2.0! |
|||
|
|||
Thanks [@CrushedPixel](https://github.com/CrushedPixel) for adding descriptions and color code support! |
|||
|
|||
Thanks [@MrMe42](https://github.com/MrMe42) for adding some minor features! |
|||
|
|||
Thanks [@tehstun](https://github.com/tehstun) for some great PRs! |
|||
|
|||
Thanks [@Benzammour](https://github.com/Benzammour) and [@haseth](https://github.com/haseth) for helping create v3! |
|||
|
|||
Thanks [@briandowns](https://github.com/briandowns) for compiling the list of spinners. |
|||
|
|||
## License |
|||
|
|||
MIT |
|||
File diff suppressed because it is too large
@ -0,0 +1,80 @@ |
|||
package progressbar |
|||
|
|||
var spinners = map[int][]string{ |
|||
0: {"←", "↖", "↑", "↗", "→", "↘", "↓", "↙"}, |
|||
1: {"▁", "▃", "▄", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▄", "▃", "▁"}, |
|||
2: {"▖", "▘", "▝", "▗"}, |
|||
3: {"┤", "┘", "┴", "└", "├", "┌", "┬", "┐"}, |
|||
4: {"◢", "◣", "◤", "◥"}, |
|||
5: {"◰", "◳", "◲", "◱"}, |
|||
6: {"◴", "◷", "◶", "◵"}, |
|||
7: {"◐", "◓", "◑", "◒"}, |
|||
8: {".", "o", "O", "@", "*"}, |
|||
9: {"|", "/", "-", "\\"}, |
|||
10: {"◡◡", "⊙⊙", "◠◠"}, |
|||
11: {"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}, |
|||
12: {">))'>", " >))'>", " >))'>", " >))'>", " >))'>", " <'((<", " <'((<", " <'((<"}, |
|||
13: {"⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"}, |
|||
14: {"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}, |
|||
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: {"⇐", "⇖", "⇑", "⇗", "⇒", "⇘", "⇓", "⇙"}, |
|||
21: {"⠁", "⠁", "⠉", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠤", "⠄", "⠄", "⠤", "⠠", "⠠", "⠤", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋", "⠉", "⠈", "⠈"}, |
|||
22: {"⠈", "⠉", "⠋", "⠓", "⠒", "⠐", "⠐", "⠒", "⠖", "⠦", "⠤", "⠠", "⠠", "⠤", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋", "⠉", "⠈"}, |
|||
23: {"⠁", "⠉", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠤", "⠄", "⠄", "⠤", "⠴", "⠲", "⠒", "⠂", "⠂", "⠒", "⠚", "⠙", "⠉", "⠁"}, |
|||
24: {"⠋", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋"}, |
|||
25: {"ヲ", "ァ", "ィ", "ゥ", "ェ", "ォ", "ャ", "ュ", "ョ", "ッ", "ア", "イ", "ウ", "エ", "オ", "カ", "キ", "ク", "ケ", "コ", "サ", "シ", "ス", "セ", "ソ", "タ", "チ", "ツ", "テ", "ト", "ナ", "ニ", "ヌ", "ネ", "ノ", "ハ", "ヒ", "フ", "ヘ", "ホ", "マ", "ミ", "ム", "メ", "モ", "ヤ", "ユ", "ヨ", "ラ", "リ", "ル", "レ", "ロ", "ワ", "ン"}, |
|||
26: {".", "..", "..."}, |
|||
27: {"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█", "▉", "▊", "▋", "▌", "▍", "▎", "▏", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁"}, |
|||
28: {".", "o", "O", "°", "O", "o", "."}, |
|||
29: {"+", "x"}, |
|||
30: {"v", "<", "^", ">"}, |
|||
31: {">>--->", " >>--->", " >>--->", " >>--->", " >>--->", " <---<<", " <---<<", " <---<<", " <---<<", "<---<<"}, |
|||
32: {"|", "||", "|||", "||||", "|||||", "|||||||", "||||||||", "|||||||", "||||||", "|||||", "||||", "|||", "||", "|"}, |
|||
33: {"[ ]", "[= ]", "[== ]", "[=== ]", "[==== ]", "[===== ]", "[====== ]", "[======= ]", "[======== ]", "[========= ]", "[==========]"}, |
|||
34: {"(*---------)", "(-*--------)", "(--*-------)", "(---*------)", "(----*-----)", "(-----*----)", "(------*---)", "(-------*--)", "(--------*-)", "(---------*)"}, |
|||
35: {"█▒▒▒▒▒▒▒▒▒", "███▒▒▒▒▒▒▒", "█████▒▒▒▒▒", "███████▒▒▒", "██████████"}, |
|||
36: {"[ ]", "[=> ]", "[===> ]", "[=====> ]", "[======> ]", "[========> ]", "[==========> ]", "[============> ]", "[==============> ]", "[================> ]", "[==================> ]", "[===================>]"}, |
|||
37: {"ဝ", "၀"}, |
|||
38: {"▌", "▀", "▐▄"}, |
|||
39: {"🌍", "🌎", "🌏"}, |
|||
40: {"◜", "◝", "◞", "◟"}, |
|||
41: {"⬒", "⬔", "⬓", "⬕"}, |
|||
42: {"⬖", "⬘", "⬗", "⬙"}, |
|||
43: {"[>>> >]", "[]>>>> []", "[] >>>> []", "[] >>>> []", "[] >>>> []", "[] >>>>[]", "[>> >>]"}, |
|||
44: {"♠", "♣", "♥", "♦"}, |
|||
45: {"➞", "➟", "➠", "➡", "➠", "➟"}, |
|||
46: {" | ", ` \ `, "_ ", ` \ `, " | ", " / ", " _", " / "}, |
|||
47: {" . . . .", ". . . .", ". . . .", ". . . .", ". . . . ", ". . . . ."}, |
|||
48: {" | ", " / ", " _ ", ` \ `, " | ", ` \ `, " _ ", " / "}, |
|||
49: {"⎺", "⎻", "⎼", "⎽", "⎼", "⎻"}, |
|||
50: {"▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸"}, |
|||
51: {"[ ]", "[ =]", "[ ==]", "[ ===]", "[====]", "[=== ]", "[== ]", "[= ]"}, |
|||
52: {"( ● )", "( ● )", "( ● )", "( ● )", "( ●)", "( ● )", "( ● )", "( ● )", "( ● )"}, |
|||
53: {"✶", "✸", "✹", "✺", "✹", "✷"}, |
|||
54: {"▐|\\____________▌", "▐_|\\___________▌", "▐__|\\__________▌", "▐___|\\_________▌", "▐____|\\________▌", "▐_____|\\_______▌", "▐______|\\______▌", "▐_______|\\_____▌", "▐________|\\____▌", "▐_________|\\___▌", "▐__________|\\__▌", "▐___________|\\_▌", "▐____________|\\▌", "▐____________/|▌", "▐___________/|_▌", "▐__________/|__▌", "▐_________/|___▌", "▐________/|____▌", "▐_______/|_____▌", "▐______/|______▌", "▐_____/|_______▌", "▐____/|________▌", "▐___/|_________▌", "▐__/|__________▌", "▐_/|___________▌", "▐/|____________▌"}, |
|||
55: {"▐⠂ ▌", "▐⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂▌", "▐ ⠠▌", "▐ ⡀▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐⠠ ▌"}, |
|||
56: {"¿", "?"}, |
|||
57: {"⢹", "⢺", "⢼", "⣸", "⣇", "⡧", "⡗", "⡏"}, |
|||
58: {"⢄", "⢂", "⢁", "⡁", "⡈", "⡐", "⡠"}, |
|||
59: {". ", ".. ", "...", " ..", " .", " "}, |
|||
60: {".", "o", "O", "°", "O", "o", "."}, |
|||
61: {"▓", "▒", "░"}, |
|||
62: {"▌", "▀", "▐", "▄"}, |
|||
63: {"⊶", "⊷"}, |
|||
64: {"▪", "▫"}, |
|||
65: {"□", "■"}, |
|||
66: {"▮", "▯"}, |
|||
67: {"-", "=", "≡"}, |
|||
68: {"d", "q", "p", "b"}, |
|||
69: {"∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙"}, |
|||
70: {"🌑 ", "🌒 ", "🌓 ", "🌔 ", "🌕 ", "🌖 ", "🌗 ", "🌘 "}, |
|||
71: {"☗", "☖"}, |
|||
72: {"⧇", "⧆"}, |
|||
73: {"◉", "◎"}, |
|||
74: {"㊂", "㊀", "㊁"}, |
|||
75: {"⦾", "⦿"}, |
|||
} |
|||
Loading…
Reference in new issue