A CLI tool for downloading from pixiv.net
修訂 | 081637a32943c1815825d7e4341edbbbcbc8e32b (tree) |
---|---|
時間 | 2023-09-29 19:40:47 |
作者 | mio <stigma@disr...> |
Commiter | mio |
Fix trailing percentage for previously downloaded
e.g.:
@@ -60,23 +60,30 @@ class ProgressMonitor | ||
60 | 60 | { |
61 | 61 | import std.conv : ConvException, to; |
62 | 62 | import std.format : format; |
63 | + import std.range : repeat; | |
64 | + import util : getTerminalColumns; | |
63 | 65 | |
64 | 66 | string value; |
65 | 67 | if (convertToString(ev.totalPages, value)) { |
66 | 68 | const numerOfDigits = value.length; |
67 | 69 | const modifier = format("%%%dd", numerOfDigits); |
68 | 70 | // ^ Determines the padding (e.g. %2d) |
69 | - const prompt = format("\r Previously downloaded page %s/%d.", | |
71 | + const msg = format("\r Previously downloaded page %s/%d.", | |
70 | 72 | modifier, ev.totalPages); |
71 | - writefln(prompt, ev.currentPage); | |
73 | + const prompt = format(msg, ev.currentPage); | |
74 | + write(prompt); | |
75 | + write(' '.repeat(getTerminalColumns() - prompt.length)); | |
72 | 76 | } else { |
73 | 77 | debug(app) |
74 | 78 | { |
75 | 79 | log.errorf("Converting size_t to string: %d", ev.totalPages); |
76 | 80 | } |
77 | - writefln("\r Previously downloaded page %d/%d.", | |
81 | + const prompt = format("\r Previously downloaded page %d/%d.", | |
78 | 82 | ev.currentPage, ev.totalPages); |
83 | + write(prompt); | |
84 | + write(' '.repeat(getTerminalColumns() - prompt.length)); | |
79 | 85 | } |
86 | + write("\n"); | |
80 | 87 | currentPage += 1; |
81 | 88 | } |
82 | 89 |