1 // =================================
 2 // Copyright (c) 2022 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 using System;
 7 using System.Collections;
 8 
 9 int main(int argcconst char** argv)
10 {
11     try
12     {
13         bool verbose = false;
14         bool parents = false;
15         List<string> directories;
16         for (int i = 1; i < argc; ++i;)
17         {
18             string arg = argv[i];
19             if (arg.StartsWith("--"))
20             {
21                 if (arg == "--help")
22                 {
23                     PrintHelp();
24                     return 1;
25                 }
26                 else if (arg == "--verbose")
27                 {
28                     verbose = true;
29                 }
30                 else if (arg == "--parents")
31                 {
32                     parents = true;
33                 }
34                 else
35                 {
36                     throw Exception("unknown argument '" + arg + "'");
37                 }
38             }
39             else if (arg.StartsWith("-"))
40             {
41                 string options = arg.Substring(1);
42                 if (options.IsEmpty())
43                 {
44                     throw Exception("unknown argument '" + arg + "'");
45                 }
46                 else
47                 {
48                     bool unknown = false;
49                     string uo;
50                     for (char o : options)
51                     {
52                         switch (o)
53                         {
54                             case 'h':
55                             {
56                                 PrintHelp();
57                                 return 1;
58                             }
59                             case 'v':
60                             {
61                                 verbose = true;
62                                 break;
63                             }
64                             case 'p':
65                             {
66                                 parents = true;
67                                 break;
68                             }
69                             default:
70                             {
71                                 unknown = true;
72                                 uo.Append(o);
73                                 break;
74                             }
75                         }
76                         if (unknown)
77                         {
78                             throw Exception("unknown option '-" + uo + "'");
79                         }
80                     }
81                 }
82             }
83             else
84             {
85                 directories.Add(arg);
86             }
87         }
88         for (const string& directory : directories)
89         {
90             MakeDirectory(directoryparentsverbose0);
91         }
92     }
93     catch (const Exception& ex)
94     {
95         Console.Error() << ex.ToString() << endl();
96         return 1;
97     }
98     return 0;
99 }