Example #1
0
        public static int ComponentMain(ComponentOptions opts)
        {
            try {
                var installer = new InstallerFrontend(opts.Offline ? InstallerFrontend.InstallerOptions.Offline : InstallerFrontend.InstallerOptions.None);

                foreach (var component_file in opts.CustomComponentFiles)
                {
                    Logger.Debug($"Adding custom component file: {component_file}");
                    installer.LoadComponentsFile(component_file);
                }

                ETGModComponent component;
                if (installer.AvailableComponents.TryGetValue(opts.Name, out component))
                {
                    Console.WriteLine($"Name: {component.Name}");
                    Console.WriteLine($"Author: {component.Author}");
                    if (component.Description.Contains("\n"))
                    {
                        Console.WriteLine($"Description:");
                        Console.WriteLine($"  {component.Description.Replace("\n", "\n  ")}");
                    }
                    else
                    {
                        Console.WriteLine($"Description: {component.Description}");
                    }
                    Console.WriteLine("Versions:");
                    foreach (var ver in component.Versions)
                    {
                        Console.WriteLine($"  {ver}");
                    }
                }
                else
                {
                    Console.WriteLine($"Component {opts.Name} doesn't exist or isn't in the official list.");
                    return(1);
                }
            } catch (Exception e) {
                _WriteError(e);
                return(1);
            }
            return(0);
        }
Example #2
0
        public static int ComponentsMain(ComponentsOptions opts)
        {
            try {
                var installer = new InstallerFrontend(opts.Offline ? InstallerFrontend.InstallerOptions.Offline : InstallerFrontend.InstallerOptions.None);

                foreach (var component_file in opts.CustomComponentFiles)
                {
                    Logger.Debug($"Adding custom component file: {component_file}");
                    installer.LoadComponentsFile(component_file);
                }

                foreach (var com in installer.AvailableComponents)
                {
                    Console.WriteLine(com.Value);
                }
            } catch (Exception e) {
                _WriteError(e);
                return(1);
            }

            return(0);
        }
Example #3
0
        public static int InstallMain(InstallOptions opts)
        {
            try {
                if (opts.Architecture != null)
                {
                    Autodetector.Architecture = (Architecture)Enum.Parse(typeof(Architecture), opts.Architecture);
                }

                var installer = new InstallerFrontend(opts.Offline ? InstallerFrontend.InstallerOptions.Offline : InstallerFrontend.InstallerOptions.None);
                if (opts.HTTP)
                {
                    installer.Options |= InstallerFrontend.InstallerOptions.HTTP;
                }
                if (opts.ForceBackup)
                {
                    installer.Options |= InstallerFrontend.InstallerOptions.ForceBackup;
                }
                if (opts.LeavePatchDLLs)
                {
                    installer.Options |= InstallerFrontend.InstallerOptions.LeavePatchDLLs;
                }
                if (opts.SkipVersionChecks)
                {
                    installer.Options |= InstallerFrontend.InstallerOptions.SkipVersionChecks;
                }

                foreach (var component_file in opts.CustomComponentFiles)
                {
                    Logger.Debug($"Adding custom component file: {component_file}");
                    installer.LoadComponentsFile(component_file);
                }

                var component_list = new List <ComponentInfo>();

                var component_strs = opts.Components.Split(';');
                foreach (var com_str in component_strs)
                {
                    var split = com_str.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
                    if (split.Length < 1 || split.Length > 2)
                    {
                        Console.WriteLine($"Improperly formatted component list - components should be separated by semicolons and may optionally have a version specified by putting '@VER' right after the name.");
                        Console.WriteLine($"Example: ETGMod;[email protected];SomethingElse;[email protected]");
                        return(1);
                    }

                    component_list.Add(new ComponentInfo(split[0], split.Length == 2 ? split[1] : null));
                }

                installer.Install(component_list, opts.Executable);
                if (Settings.Instance.UnityDebug)
                {
                    installer.InstallUnityDebug();
                }
                if (Settings.Instance.ILDebug)
                {
                    installer.InstallILDebug();
                }
                return(0);
            } catch (Exception e) {
                _WriteError(e);
                return(1);
            }
        }