[mtouch] Make the 'action' a local variable instead of a global one.
Make the 'action' a local variable instead of a global one so that argument parsing can be done multiple times.
This commit is contained in:
Родитель
052c2e9753
Коммит
d2498370d9
|
@ -113,8 +113,6 @@ namespace Xamarin.Bundler
|
||||||
LaunchWatchApp,
|
LaunchWatchApp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Action action;
|
|
||||||
|
|
||||||
static bool xcode_version_check = true;
|
static bool xcode_version_check = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -332,7 +330,7 @@ namespace Xamarin.Bundler
|
||||||
return output.ToString ().Trim ();
|
return output.ToString ().Trim ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ValidateXcode ()
|
static void ValidateXcode (Action action)
|
||||||
{
|
{
|
||||||
// Allow a few actions, since these seem to always work no matter the Xcode version.
|
// Allow a few actions, since these seem to always work no matter the Xcode version.
|
||||||
var accept_any_xcode_version = action == Action.ListDevices || action == Action.ListCrashReports || action == Action.ListApps || action == Action.LogDev;
|
var accept_any_xcode_version = action == Action.ListDevices || action == Action.ListCrashReports || action == Action.ListApps || action == Action.LogDev;
|
||||||
|
@ -960,31 +958,9 @@ namespace Xamarin.Bundler
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetAction (Action value)
|
|
||||||
{
|
|
||||||
switch (action) {
|
|
||||||
case Action.None:
|
|
||||||
action = value;
|
|
||||||
break;
|
|
||||||
case Action.KillApp:
|
|
||||||
if (value == Action.LaunchDevice) {
|
|
||||||
action = Action.KillAndLaunch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
goto default;
|
|
||||||
case Action.LaunchDevice:
|
|
||||||
if (value == Action.KillApp) {
|
|
||||||
action = Action.KillAndLaunch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
goto default;
|
|
||||||
default:
|
|
||||||
throw new MonoTouchException (19, true, "Only one --[log|install|kill|launch]dev or --[launch|debug|list]sim option can be used.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int Main2 (string [] args)
|
static int Main2 (string [] args)
|
||||||
{
|
{
|
||||||
|
var action = Action.None;
|
||||||
var app = new Application ();
|
var app = new Application ();
|
||||||
var assemblies = new List<string> ();
|
var assemblies = new List<string> ();
|
||||||
|
|
||||||
|
@ -998,6 +974,29 @@ namespace Xamarin.Bundler
|
||||||
string tls_provider = null;
|
string tls_provider = null;
|
||||||
string http_message_handler = null;
|
string http_message_handler = null;
|
||||||
|
|
||||||
|
Action<Action> SetAction = (Action value) =>
|
||||||
|
{
|
||||||
|
switch (action) {
|
||||||
|
case Action.None:
|
||||||
|
action = value;
|
||||||
|
break;
|
||||||
|
case Action.KillApp:
|
||||||
|
if (value == Action.LaunchDevice) {
|
||||||
|
action = Action.KillAndLaunch;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
goto default;
|
||||||
|
case Action.LaunchDevice:
|
||||||
|
if (value == Action.KillApp) {
|
||||||
|
action = Action.KillAndLaunch;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
goto default;
|
||||||
|
default:
|
||||||
|
throw new MonoTouchException (19, true, "Only one --[log|install|kill|launch]dev or --[launch|debug|list]sim option can be used.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var os = new OptionSet () {
|
var os = new OptionSet () {
|
||||||
{ "h|?|help", "Displays the help", v => SetAction (Action.Help) },
|
{ "h|?|help", "Displays the help", v => SetAction (Action.Help) },
|
||||||
{ "version", "Output version information and exit.", v => SetAction (Action.Version) },
|
{ "version", "Output version information and exit.", v => SetAction (Action.Version) },
|
||||||
|
@ -1293,7 +1292,7 @@ namespace Xamarin.Bundler
|
||||||
|
|
||||||
app.RuntimeOptions = RuntimeOptions.Create (app, http_message_handler, tls_provider);
|
app.RuntimeOptions = RuntimeOptions.Create (app, http_message_handler, tls_provider);
|
||||||
|
|
||||||
ValidateXcode ();
|
ValidateXcode (action);
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
/* Device actions */
|
/* Device actions */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче