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