-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobal.cs
71 lines (66 loc) · 1.34 KB
/
Global.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
namespace CopyDb
{
class Global
{
[STAThread]
static int Main (string[] args)
{
Stopwatch sw = new Stopwatch();
sw.Start();
bool overwriteExistingDatabase = false;
DbInfo source = null;
DbInfo dest = null;
var positional = 0;
foreach (var arg in args)
{
if (arg[0] == '-' || arg[0] == '/')
{
if (arg.Length < 2)
return ShowUsage();
switch (arg[1])
{
case '?':
case 'h':
return ShowUsage();
case 'f':
overwriteExistingDatabase = true;
break;
default:
return ShowUsage();
}
}
else
{
switch (++positional)
{
case 1:
source = new DbInfo(arg);
break;
case 2:
dest = new DbInfo(arg);
break;
}
}
}
if (positional < 2)
return ShowUsage();
try
{
new Copier(source, dest, overwriteExistingDatabase).Run();
return 0;
}
finally
{
sw.Stop();
Console.WriteLine("\n\nElapsed time = {0:0.000} seconds", sw.Elapsed.TotalSeconds);
}
}
private static int ShowUsage ()
{
Console.WriteLine("Usage: CopyDb fromServer;fromDb[;usr;pwd] toServer;toDb[;usr;pwd]");
Console.WriteLine("\t-f\tForce overwriting existing destination database");
return 1;
}
}
}