A CLI tool for downloading from pixiv.net
Révision | 795061d31427f4182928a4275d3fd9aabd5a8619 (tree) |
---|---|
l'heure | 2023-06-15 12:12:55 |
Auteur | mio <stigma@disr...> |
Commiter | mio |
Provide better default help message
This will be displayed when there are no arguments provided or
when -h/--help/help is provided.
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* |
2 | 2 | * pixiv_down - CLI-based downloading tool for https://www.pixiv.net. |
3 | - * Copyright (C) 2023 mio <stigma@disroot.org> | |
3 | + * Copyright (C) 2023 Mio | |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
@@ -670,6 +670,32 @@ void printMainHelp(string progname, string msg = "") | ||
670 | 670 | "available options"); |
671 | 671 | } |
672 | 672 | |
673 | +void displayDefaultHelp(string programName) | |
674 | +{ | |
675 | + stderr.writefln( | |
676 | + "pixiv_down - A tool for downloading from pixiv.net [version %s]\n" ~ | |
677 | + "\nUsage:\t%s <command> [options]\n" ~ | |
678 | + "\npixiv_down is a tool that allows you to download various content\n" ~ | |
679 | + "from the pixiv website. Currently it's limited to illustrations,\n" ~ | |
680 | + "however, work is being made on providing support for novels.\n" ~ | |
681 | + "\nMain Commands:\n" ~ | |
682 | + "\tartist \tDownload content from a specified artist.\n" ~ | |
683 | + "\tartwork \tDownload a specific artwork(s) via IDs.\n" ~ | |
684 | + "\tdaily \tDownload all followed users' content between dates.\n" ~ | |
685 | + "\tfollowing\tDownload all followed users' content by account.\n" ~ | |
686 | + "\nSide Commands:\n" ~ | |
687 | + "\thelp \tDisplay this help information and exit.\n" ~ | |
688 | + "\tversion \tDisplay the current version of pixiv_down.\n" ~ | |
689 | + "\nExamples:\n" ~ | |
690 | + "\n Download a single illustration:\n" ~ | |
691 | + " pixiv_down artwork 108985926\n" ~ | |
692 | + "\n Download all content from a user:\n" ~ | |
693 | + " pixiv_down artist 10109777\n" ~ | |
694 | + "\nYou can combine ``help'' with any of the main commands for more\n" ~ | |
695 | + "information and examples on the chosen command.", | |
696 | + PixivDownVersionString, programName); | |
697 | +} | |
698 | + | |
673 | 699 | // Don't compile in |main| when building unittests. |
674 | 700 | version(unittest) {} else: |
675 | 701 |
@@ -688,15 +714,15 @@ version(appimage) { | ||
688 | 714 | ]; |
689 | 715 | |
690 | 716 | if (args.length < 2) { |
691 | - printMainHelp(args[0], "no command specified"); | |
692 | - return 1; | |
717 | + displayDefaultHelp(args[0]); | |
718 | + return 2; | |
693 | 719 | } |
694 | 720 | |
695 | 721 | switch (args[1]) { |
696 | 722 | case "-h": |
697 | 723 | case "--help": |
698 | 724 | case "help": |
699 | - printMainHelp(args[0]); | |
725 | + displayDefaultHelp(args[0]); | |
700 | 726 | return 0; |
701 | 727 | case "-v": |
702 | 728 | case "--version": |