better help output formatting (Issue #298)

This commit is contained in:
Norbert Preining 2018-12-28 18:01:50 +09:00 committed by GitHub
parent f7a50c0d97
commit b9890ae2e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}
}