From b9890ae2e57d7df00736beb57a35522e4f0a2c15 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 28 Dec 2018 18:01:50 +0900 Subject: [PATCH] better help output formatting (Issue #298) --- src/main.d | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/main.d b/src/main.d index 4113d71e..8a5c4fbd 100644 --- a/src/main.d +++ b/src/main.d @@ -101,18 +101,14 @@ int main(string[] args) "single-directory", "Specify a single local directory within the OneDrive root to sync.", &singleDirectory, "skip-symlinks", "Skip syncing of symlinks", &skipSymlinks, "source-directory", "Source directory to rename or move on OneDrive - no sync will be performed.", &sourceDirectory, - "syncdir", "Set the directory used to sync the files that are synced", &syncDirName, + "syncdir", "Specify the local directory used for synchronization to OneDrive", &syncDirName, "synchronize", "Perform a synchronization", &synchronize, "upload-only", "Only upload to OneDrive, do not sync changes from OneDrive locally", &uploadOnly, "verbose|v+", "Print more details, useful for debugging (repeat for extra debugging)", &log.verbose, "version", "Print the version and exit", &printVersion ); if (opt.helpWanted) { - defaultGetoptPrinter( - "Usage: onedrive [OPTION]...\n\n" ~ - "no option No sync and exit", - opt.options - ); + outputLongHelp(opt.options); return EXIT_SUCCESS; } } catch (GetOptException e) { @@ -675,3 +671,41 @@ extern(C) nothrow @nogc @system void exitHandler(int value) { } catch(Exception e) {} exit(0); } +void outputLongHelp(Option[] opt) +{ + auto argsNeedingOptions = [ + "--confdir", + "--create-directory", + "--destination-directory", + "--get-O365-drive-id", + "--remove-directory", + "--single-directory", + "--source-directory", + "--syncdir" ]; + writeln(`OneDrive - a client for OneDrive Cloud Services + +Usage: + onedrive [options] --synchronize + Do a one time synchronization + onedrive [options] --monitor + Monitor filesystem and sync regularly + onedrive [options] --display-config + Display the currently used configuration + onedrive [options] --display-sync-status + Query OneDrive service and report on pending changes + onedrive -h | --help + Show this help screen + onedrive --version + Show version + +Options: +`); + foreach (it; opt) { + writefln(" %s%s%s%s\n %s", + it.optShort == "" ? "" : it.optShort ~ " ", + it.optLong, + argsNeedingOptions.canFind(it.optLong) ? " ARG" : "", + it.required ? " (required)" : "", it.help); + } +} +