blob: abc7c6d7d4a70afc2fb39e86ecde74a193b02132 (
plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#include "UpdaterOptions.h"
#include "Log.h"
#include "AnyOption/anyoption.h"
#include "FileUtils.h"
#include "Platform.h"
#include "StringUtils.h"
#include <cstdlib>
#include <iostream>
UpdaterOptions::UpdaterOptions()
: mode(UpdateInstaller::Setup)
, waitPid(0)
, showVersion(false)
, forceElevated(false)
, autoClose(false)
{
}
UpdateInstaller::Mode stringToMode(const std::string& modeStr)
{
if (modeStr == "main")
{
return UpdateInstaller::Main;
}
else
{
if (!modeStr.empty())
{
LOG(Error,"Unknown mode " + modeStr);
}
return UpdateInstaller::Setup;
}
}
void UpdaterOptions::parse(int argc, char** argv)
{
AnyOption parser;
parser.setOption("install-dir");
parser.setOption("package-dir");
parser.setOption("finish-cmd");
parser.setOption("finish-dir");
parser.setOption("script");
parser.setOption("wait");
parser.setOption("mode");
parser.setFlag("version");
parser.setFlag("force-elevated");
parser.setFlag("dry-run");
parser.setFlag("auto-close");
parser.processCommandArgs(argc,argv);
if (parser.getValue("mode"))
{
mode = stringToMode(parser.getValue("mode"));
}
if (parser.getValue("install-dir"))
{
installDir = parser.getValue("install-dir");
}
if (parser.getValue("package-dir"))
{
packageDir = parser.getValue("package-dir");
}
if (parser.getValue("script"))
{
scriptPath = parser.getValue("script");
}
if (parser.getValue("wait"))
{
waitPid = static_cast<PLATFORM_PID>(atoll(parser.getValue("wait")));
}
if (parser.getValue("finish-cmd"))
{
finishCmd = parser.getValue("finish-cmd");
}
if (parser.getValue("finish-dir"))
{
finishDir = parser.getValue("finish-dir");
}
showVersion = parser.getFlag("version");
forceElevated = parser.getFlag("force-elevated");
dryRun = parser.getFlag("dry-run");
autoClose = parser.getFlag("auto-close");
}
|