Beispiel #1
0
        public void Setup()
        {
            // Make sure curl is all set up.
            Curl.Init();

            // Give us a registry to play with.
            ksp      = new DisposableKSP();
            manager  = CKAN.RegistryManager.Instance(ksp.KSP);
            registry = manager.registry;
            registry.ClearDlls();
            registry.Installed().Clear();
            // Make sure we have a registry we can use.
            CKAN.Repo.Update(manager, ksp.KSP, new NullUser(), TestData.TestKANZip());

            // Ready our downloader.
            async = new CKAN.NetAsyncModulesDownloader(new NullUser());

            // General shortcuts
            cache = ksp.KSP.Cache;
        }
Beispiel #2
0
        public void Setup()
        {
            // Make sure curl is all set up.
            Curl.Init();

            // Give us a registry to play with.
            ksp      = new DisposableKSP();
            registry = ksp.KSP.Registry;

            registry.ClearAvailable();
            registry.ClearPreexistingModules();
            registry.Installed().Clear();

            // Make sure we have a registry we can use.
            CKAN.Repo.UpdateRegistry(TestData.TestKANZip(), registry, ksp.KSP, new NullUser());

            // Ready our downloader.
            async = new CKAN.NetAsyncModulesDownloader(new NullUser(), ksp.KSP.tryGetFactorioAuthData());

            // General shortcuts
            cache = ksp.KSP.Cache;
        }
Beispiel #3
0
        public static int Main(string[] args)
        {
            // Launch debugger if the "--debugger" flag is present in the command line arguments.
            // We want to do this as early as possible so just check the flag manually, rather than doing the
            // more robust argument parsing.
            if (args.Any(i => i == "--debugger"))
            {
                Debugger.Launch();
            }

            // Default to GUI if there are no command line args or if the only args are flags rather than commands.
            if (args.All(a => a == "--verbose" || a == "--debug" || a == "--asroot" || a == "--show-console"))
            {
                var guiCommand = args.ToList();
                guiCommand.Insert(0, "gui");
                args = guiCommand.ToArray();
            }

            Logging.Initialize();
            log.Info("CKAN started.");

            // Force-allow TLS 1.2 for HTTPS URLs, because GitHub requires it.
            // This is on by default in .NET 4.6, but not in 4.5.
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

            // Make sure Curl is all set up
            Curl.Init();

            try
            {
                return(Execute(null, null, args));
            }
            finally
            {
                RegistryManager.DisposeAll();
            }
        }
Beispiel #4
0
        public static int Main(string[] args)
        {
            try
            {
                ProcessArgs(args);

                // Force-allow TLS 1.2 for HTTPS URLs, because GitHub requires it.
                // This is on by default in .NET 4.6, but not in 4.5.
                ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

                // If we see the --version flag, then display our build info
                // and exit.
                if (Options.Version)
                {
                    Console.WriteLine(Meta.GetVersion(VersionFormat.Full));
                    return(ExitOk);
                }

                // Make sure Curl is all set up
                Curl.Init();

                if (!string.IsNullOrEmpty(Options.ValidateCkan))
                {
                    var ckan = new Metadata(JObject.Parse(File.ReadAllText(Options.ValidateCkan)));
                    var inf  = new Inflator(
                        Options.CacheDir,
                        Options.OverwriteCache,
                        Options.GitHubToken,
                        Options.PreRelease
                        );
                    inf.ValidateCkan(ckan);
                    Console.WriteLine(QueueHandler.serializeCkan(
                                          new PropertySortTransformer().Transform(ckan, null).First()
                                          ));
                    return(ExitOk);
                }

                if (!string.IsNullOrEmpty(Options.Queues))
                {
                    var queues = Options.Queues.Split(new char[] { ',' }, 2);
                    var qh     = new QueueHandler(
                        queues[0],
                        queues[1],
                        Options.CacheDir,
                        Options.OverwriteCache,
                        Options.GitHubToken,
                        Options.PreRelease
                        );
                    qh.Process();
                    return(ExitOk);
                }

                if (Options.File != null)
                {
                    Log.InfoFormat("Transforming {0}", Options.File);

                    var netkan = ReadNetkan();
                    Log.Info("Finished reading input");

                    var inf = new Inflator(
                        Options.CacheDir,
                        Options.OverwriteCache,
                        Options.GitHubToken,
                        Options.PreRelease
                        );
                    var ckans = inf.Inflate(
                        Options.File,
                        netkan,
                        new TransformOptions(
                            ParseReleases(Options.Releases),
                            ParseSkipReleases(Options.SkipReleases),
                            ParseHighestVersion(Options.HighestVersion)
                            )
                        );
                    foreach (Metadata ckan in ckans)
                    {
                        WriteCkan(ckan);
                    }
                }
                else
                {
                    Log.Fatal(
                        "Usage: netkan [--verbose|--debug] [--debugger] [--prerelease] [--outputdir=...] <filename>"
                        );
                    return(ExitBadOpt);
                }
            }
            catch (Exception e)
            {
                e = e.GetBaseException();

                Log.Fatal(e.Message);

                if (Options == null || Options.Debug)
                {
                    Log.Fatal(e.StackTrace);
                }

                return(ExitError);
            }

            return(ExitOk);
        }