Skip to content

Commit 2a19723

Browse files
committed
Improve --help example indentation
Fixes #1.
1 parent f32b57f commit 2a19723

File tree

1 file changed

+28
-5
lines changed
  • source/reloadedvibes

1 file changed

+28
-5
lines changed

source/reloadedvibes/app.d

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@ int main(string[] args)
182182

183183
if (optSocketWebServer !is null)
184184
{
185+
// dfmt off
185186
stdout.writeln();
186187
stdout.writeln("Built-in webserver: ", webserver.toString);
187188
stdout.writeln("Serving: ", optDocumentRootWebServer.absolutePath);
188189
stdout.writeln("Script injection: ", ((optNoInjectWebServer) ? "disabled" : "enabled"));
190+
// dfmt on
189191
}
190192

191193
stdout.writeln();
@@ -200,11 +202,32 @@ int main(string[] args)
200202

201203
void printHelp(string args0, GetoptResult opt)
202204
{
203-
defaultGetoptPrinter(appName ~ "\n\n Usage:\n " ~ args0
204-
~ " <options>\n\n Example:\n " ~ args0 ~ " --socket=127.0.0.1:3001"
205-
~ "\n --watch=./src --watch=./sass"
206-
~ "\n --action=\"npm run build\" --action=\"./refreshDB.sh\""
207-
~ "\n\nAvailable options:\n==================", opt.options);
205+
// Ideally, this help text will not exceed a size of
206+
// 80x23, so that it's fully visible on an 80x24 terminal.
207+
208+
size_t getIndent()
209+
{
210+
immutable l = args0.length + 5;
211+
return (l <= 29) ? l : 8;
212+
}
213+
214+
string makeIndent()
215+
{
216+
enum indent = " ";
217+
return indent[0 .. getIndent()];
218+
}
219+
220+
immutable indent = makeIndent();
221+
222+
// dfmt off
223+
defaultGetoptPrinter(
224+
appName ~ "\n\n Usage:\n " ~ args0 ~ " <options>\n\n Example:\n "
225+
~ args0 ~ " --socket=127.0.0.1:3001\n"
226+
~ indent ~ "--watch=./src --watch=./sass\n"
227+
~ indent ~ "--action=\"npm run build\" --action=\"./refreshDB.sh\""
228+
~ "\n\nAvailable options:\n==================",
229+
opt.options
230+
);
208231
}
209232

210233
void printVersionInfo()

0 commit comments

Comments
 (0)