• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A CLI tool for downloading from pixiv.net


Commit MetaInfo

Revision8dbbeef616745b389f9f6d256d1fbe966d3ac1a4 (tree)
Time2023-09-27 17:27:55
Authormio <stigma@disr...>
Commitermio

Log Message

Pad 'Already downloaded page X' values

Also considering changing the message to 'Already downloaded page x/y'

Change Summary

Incremental Difference

--- a/dub.sdl
+++ b/dub.sdl
@@ -18,7 +18,7 @@ dependency "magickd:graphicsmagick_c" \
1818
1919 dependency "pixivd" \
2020 repository="git+https://pf.osdn.net/gitroot/n/ne/nemophila/pixivd.git" \
21- version="1085361d86366542741e8ae5b845fed74c0a8aa5"
21+ version="c9a28e4f8521840f3919c5a38817906e6be1fdef"
2222
2323 ########################################################
2424 # If you are using the "fetch_dependencies.sh" script, #
--- /dev/null
+++ b/dub.selections.json
@@ -0,0 +1,7 @@
1+{
2+ "fileVersion": 1,
3+ "versions": {
4+ "magickd": {"version":"dd4985919d78d0cf37ab4b2ab99bb2ecec6aec15","repository":"git+https://repo.or.cz/magickd.git"},
5+ "pixivd": {"version":"c9a28e4f8521840f3919c5a38817906e6be1fdef","repository":"git+https://pf.osdn.net/gitroot/n/ne/nemophila/pixivd.git"}
6+ }
7+}
--- a/source/app.d
+++ b/source/app.d
@@ -48,21 +48,31 @@ import pixivd.client;
4848
4949 class ProgressMonitor
5050 {
51+ import std.format : format;
52+ import util : getTerminalColumns;
53+
5154 size_t currentImage = 1;
5255
5356 void alreadyComplete(PageAlreadyDownloadedEvent ev)
5457 {
55- import std.format : format;
56- import util : getTerminalColumns;
57-
58- string prompt = "\r Already downloaded page %d.".format(currentImage);
59- size_t remLength = getTerminalColumns() - prompt.length;
60-
61- write(prompt);
62- for (int i = 0; i < remLength; i++) {
63- write(' ');
58+ import std.conv : ConvException, to;
59+
60+ size_t promptLength = 0;
61+
62+ try {
63+ const numberOfDigits = to!string(ev.totalPages).length;
64+ const modifier = format("%%%dd", numberOfDigits);
65+ const promptWM = format("\r Already downloaded page %s.",
66+ modifier);
67+ writefln(promptWM, currentImage);
68+ } catch (ConvException ce) {
69+ debug(app)
70+ {
71+ stderr.writefln("ERORR converting size_t to string");
72+ stderr.writefln(" --> %s", ce.msg);
73+ }
74+ writefln("\r Already downloaded page %d.", currentImage);
6475 }
65- write('\n');
6676 currentImage += 1;
6777 }
6878
@@ -84,10 +94,18 @@ class ProgressMonitor
8494
8595 void complete(DownloadCompleteEvent ev)
8696 {
87- write('\n');
8897 if (ev.forPage) {
98+ string prompt = "\r Downloaded page %d.".format(currentImage);
99+ size_t remLength = getTerminalColumns() - prompt.length;
100+
101+ write(prompt);
102+ for (int i = 0; i < remLength; i++) {
103+ write(' ');
104+ }
105+
89106 currentImage += 1;
90107 }
108+ write('\n');
91109 }
92110 }
93111