Decorators package doc comments
Vladimir Bauer
8 years ago
| 47 | 47 | bar := p.AddBar(int64(total), |
| 48 | 48 | // Prepending decorators |
| 49 | 49 | mpb.PrependDecorators( |
| 50 | // StaticName decorator with minWidth and no width sync options | |
| 50 | // StaticName decorator with minWidth and no extra config | |
| 51 | 51 | // If you need to change name while rendering, use DynamicName |
| 52 | 52 | decor.StaticName(name, len(name), 0), |
| 53 | // ETA decorator with minWidth and width sync options | |
| 54 | // DSyncSpace is shortcut for DwidthSync|DextraSpace | |
| 55 | decor.ETA(4, decor.DSyncSpace), | |
| 53 | // ETA decorator with minWidth and no extra config | |
| 54 | decor.ETA(4, 0), | |
| 56 | 55 | ), |
| 57 | 56 | // Appending decorators |
| 58 | 57 | mpb.AppendDecorators( |
| 59 | // Percentage decorator with minWidth and no width sync options | |
| 58 | // Percentage decorator with minWidth and no extra config | |
| 60 | 59 | decor.Percentage(5, 0), |
| 61 | 60 | ), |
| 62 | 61 | ) |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // DynamicName to be used, when there is a plan to change the name once or |
| 64 | // several times during progress rendering process | |
| 64 | // several times during progress rendering process. If there're more than one | |
| 65 | // bar, and you'd like to synchronize column width, conf param shauld have | |
| 66 | // DwidthSync bit set. | |
| 65 | 67 | func DynamicName(nameFn func(*Statistics) string, minWidth int, conf byte) DecoratorFunc { |
| 66 | 68 | format := "%%" |
| 67 | 69 | if (conf & DidentRight) != 0 { |
| 85 | 87 | // Counters provides basic counters decorator. |
| 86 | 88 | // Accepts pairFormat string, something like "%s / %s" to be used in |
| 87 | 89 | // fmt.Sprintf(pairFormat, current, total) and one of (Unit_KiB/Unit_kB) |
| 88 | // constant | |
| 90 | // constant. If there're more than one bar, and you'd like to synchronize column | |
| 91 | // width, conf param shauld have DwidthSync bit set. | |
| 89 | 92 | func Counters(pairFormat string, unit Units, minWidth int, conf byte) DecoratorFunc { |
| 90 | 93 | format := "%%" |
| 91 | 94 | if (conf & DidentRight) != 0 { |
| 108 | 111 | } |
| 109 | 112 | } |
| 110 | 113 | |
| 114 | // ETA provides exponential-weighted-moving-average ETA decorator. | |
| 115 | // If there're more than one bar, and you'd like to synchronize column width, | |
| 116 | // conf param shauld have DwidthSync bit set. | |
| 111 | 117 | func ETA(minWidth int, conf byte) DecoratorFunc { |
| 112 | 118 | format := "%%" |
| 113 | 119 | if (conf & DidentRight) != 0 { |
| 128 | 134 | } |
| 129 | 135 | } |
| 130 | 136 | |
| 137 | // Elapsed provides elapsed time decorator. | |
| 138 | // If there're more than one bar, and you'd like to synchronize column width, | |
| 139 | // conf param shauld have DwidthSync bit set. | |
| 131 | 140 | func Elapsed(minWidth int, conf byte) DecoratorFunc { |
| 132 | 141 | format := "%%" |
| 133 | 142 | if (conf & DidentRight) != 0 { |
| 148 | 157 | } |
| 149 | 158 | } |
| 150 | 159 | |
| 160 | // Percentage provides percentage decorator. | |
| 161 | // If there're more than one bar, and you'd like to synchronize column width, | |
| 162 | // conf param shauld have DwidthSync bit set. | |
| 151 | 163 | func Percentage(minWidth int, conf byte) DecoratorFunc { |
| 152 | 164 | format := "%%" |
| 153 | 165 | if (conf & DidentRight) != 0 { |
| 24 | 24 | bar := p.AddBar(int64(total), |
| 25 | 25 | // Prepending decorators |
| 26 | 26 | mpb.PrependDecorators( |
| 27 | // StaticName decorator with minWidth and no width sync options | |
| 27 | // StaticName decorator with minWidth and no extra config | |
| 28 | 28 | // If you need to change name while rendering, use DynamicName |
| 29 | 29 | decor.StaticName(name, len(name), 0), |
| 30 | // ETA decorator with minWidth and width sync options | |
| 31 | // DSyncSpace is shortcut for DwidthSync|DextraSpace | |
| 32 | decor.ETA(4, decor.DSyncSpace), | |
| 30 | // ETA decorator with minWidth and no extra config | |
| 31 | decor.ETA(4, 0), | |
| 33 | 32 | ), |
| 34 | 33 | // Appending decorators |
| 35 | 34 | mpb.AppendDecorators( |
| 36 | // Percentage decorator with minWidth and no width sync options | |
| 35 | // Percentage decorator with minWidth and no extra config | |
| 37 | 36 | decor.Percentage(5, 0), |
| 38 | 37 | ), |
| 39 | 38 | ) |
| 24 | 24 | bar := p.AddBar(int64(total), |
| 25 | 25 | // Prepending decorators |
| 26 | 26 | mpb.PrependDecorators( |
| 27 | // StaticName decorator with minWidth and no width sync options | |
| 27 | // StaticName decorator with minWidth and no extra config | |
| 28 | 28 | // If you need to change name while rendering, use DynamicName |
| 29 | 29 | decor.StaticName(name, len(name), 0), |
| 30 | // ETA decorator with minWidth and width sync options | |
| 31 | // DSyncSpace is shortcut for DwidthSync|DextraSpace | |
| 32 | decor.ETA(4, decor.DSyncSpace), | |
| 30 | // ETA decorator with minWidth and no extra config | |
| 31 | decor.ETA(4, 0), | |
| 33 | 32 | ), |
| 34 | 33 | // Appending decorators |
| 35 | 34 | mpb.AppendDecorators( |
| 36 | // Percentage decorator with minWidth and no width sync options | |
| 35 | // Percentage decorator with minWidth and no extra config | |
| 37 | 36 | decor.Percentage(5, 0), |
| 38 | 37 | ), |
| 39 | 38 | ) |