summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Shields <mail@kennyshields.net>2020-07-29 22:26:59 -0400
committerKenny Shields <mail@kennyshields.net>2020-07-29 22:26:59 -0400
commit1d07cbeb239a1895908156e079fcf17c7ba75689 (patch)
treeec6809433bf97433be5c45de87a30cdbfc0ea98c
parentd0f26d38a6266c83809a65c5484d6ac1ab89d479 (diff)
downloaddsymlist-1d07cbeb239a1895908156e079fcf17c7ba75689.tar.gz
dsymlist-1d07cbeb239a1895908156e079fcf17c7ba75689.zip
Catch exceptions from getopt function call
-rw-r--r--source/main.d42
1 files changed, 24 insertions, 18 deletions
diff --git a/source/main.d b/source/main.d
index 1c33b65..0ef765c 100644
--- a/source/main.d
+++ b/source/main.d
@@ -8,7 +8,7 @@ import std.path : baseName;
import std.array : join, split;
import std.string : splitLines;
import std.regex : matchFirst, regex;
-import std.getopt : getopt, config;
+import std.getopt : getopt, config, GetoptResult;
import std.algorithm.sorting : sort;
import std.algorithm.searching : startsWith;
import std.conv : to;
@@ -66,23 +66,29 @@ ulong namespaceCount = 0;
*/
void main(string[] args) {
// check options
- auto helpInfo = getopt(args, config.passThrough,
- "quiet|q",
- "Don't print to standard out.",
- &__opt_quiet,
- "outfile|o",
- "Writes output to the specified file.",
- &__opt_outFile,
- "mangle|m",
- "Include mangled symbol in output.",
- &__opt_showMangle,
- "spacing|s",
- "Add extra spacing for less compact output.",
- &__opt_extraSpacing,
- "namespace|n",
- "Comma-separated list of namespaces to restrict the symbols collection to.",
- &__opt_nameSpaces
- );
+ GetoptResult helpInfo;
+ try {
+ helpInfo = getopt(args, config.passThrough,
+ "quiet|q",
+ "Don't print to standard out.",
+ &__opt_quiet,
+ "outfile|o",
+ "Writes output to the specified file.",
+ &__opt_outFile,
+ "mangle|m",
+ "Include mangled symbol in output.",
+ &__opt_showMangle,
+ "spacing|s",
+ "Add extra spacing for less compact output.",
+ &__opt_extraSpacing,
+ "namespace|n",
+ "Comma-separated list of namespaces to restrict the symbols collection to.",
+ &__opt_nameSpaces
+ );
+ } catch(Exception e) {
+ writeln("Invalid option.");
+ return;
+ }
if(helpInfo.helpWanted) {
writeln("dsymlist - List D language symbols in a binary file.");
writeln("\t");