public BootstrapProcess([NotNull] ITaskHandler handler, bool gui) : base(handler)
{
_gui = gui;
_options = new OptionSet
{
{
"?|h|help", () => "Show the built-in help text.", _ =>
{
Handler.Output("Help", HelpText);
throw new OperationCanceledException(); // Don't handle any of the other arguments
}
},
{
"batch", () => "Automatically answer questions with defaults when possible. Avoid unnecessary console output (e.g. progress bars).", _ =>
{
if (Handler.Verbosity >= Verbosity.Verbose) throw new OptionException("Cannot combine --batch and --verbose", "verbose");
Handler.Verbosity = Verbosity.Batch;
}
},
{
"v|verbose", () => "More verbose output. Use twice for even more verbose output.", _ =>
{
if (Handler.Verbosity == Verbosity.Batch) throw new OptionException("Cannot combine --batch and --verbose", "batch");
Handler.Verbosity++;
}
},
{
"no-existing", () => "Do not detect and use existing Zero Install instances. Always use downloaded and cached instance.", _ => _noExisting = true
},
{
"version=", () => "Select a specific {VERSION} of Zero Install. Implies --no-existing.", (VersionRange range) =>
{
_version = range;
_noExisting = true;
}
},
{
"feed=", () => "Specify an alternative {FEED} for Zero Install. Must be an absolute URI. Implies --no-existing.", feed =>
{
Config.SelfUpdateUri = new FeedUri(feed);
_noExisting = true;
}
},
{
"content-dir=", () => "Specifies a {DIRECTORY} to search for feeds and archives to import. The default is a directory called 'content'.", path =>
{
if (!Directory.Exists(path)) throw new DirectoryNotFoundException($"Directory '{path}' not found.");
_contentDir = path;
}
},
{
"o|offline", () => "Run in off-line mode, not downloading anything.", _ => Config.NetworkUse = NetworkLevel.Offline
},
// Disable interspersed arguments (needed for passing arguments through to target)
{
"<>", value =>
{
_targetArgs.Add(value);
// Stop using options parser, treat everything from here on as unknown
_options.Clear();
}
}
};
if (EmbeddedConfig.Instance.AppMode == BootstrapMode.None)
{
_options.Add("silent", () => "Deploy Zero Install in unattended mode. Equivalent to \"maintenance deploy --batch\".", _ =>
{
_targetArgs.Clear();
_targetArgs.AddRange(new[] {"maintenance", "deploy", "--batch"});
if (!IsPerUser) _targetArgs.Add("--machine");
});
_options.Add("verysilent", () => "Deploy Zero Install in unattended mode with no UI. Equivalent to \"maintenance deploy --batch --background\".", _ =>
{
_targetArgs.Clear();
_targetArgs.AddRange(new[] {"maintenance", "deploy", "--batch", "--background"});
if (!IsPerUser) _targetArgs.Add("--machine");
});
}
}
#endregion