Example #1
0
        private static int Pull(PullOptions opts)
        {
            string path = VersionManager.GetInstallationPath(opts.Version, opts.Tier ? ServerTier.Pro : ServerTier.Free, opts.Platform);

            if (path == null)
            {
                return(1);
            }

            return(0);
        }
Example #2
0
        private static int Pull(PullOptions opts)
        {
            // If --list was specified, list installed versions and tell if documentation for that version is available locally
            if (opts.List)
            {
                VersionManager.ListInstalledVersions();
                return(0);
            }

            // if version provided is "latest", it is being replaced with currently most recent one
            if (opts.Version == "latest")
            {
                opts.Version = VersionManager.GetLatestDarkRiftVersion();
            }

            if (opts.Version == null)
            {
                // if version info was omitted, overwrite any parameters with current project settings
                if (Project.Loaded)
                {
                    opts.Version  = Project.Runtime.Version;
                    opts.Platform = Project.Runtime.Platform;
                    opts.Pro      = Project.Runtime.Tier == ServerTier.Pro;
                }
                else
                {
                    Console.Error.WriteLine(Output.Red($"Couldn't find a version to install. To download latest version use \"latest\" as the version"));
                    return(2);
                }
            }

            ServerTier actualTier = opts.Pro ? ServerTier.Pro : ServerTier.Free;

            // If --docs was specified, download documentation instead
            bool success = false;

            if (opts.Docs)
            {
                bool docsInstalled = VersionManager.IsDocumentationInstalled(opts.Version);

                if (docsInstalled && !opts.Force)
                {
                    Console.WriteLine(Output.Green($"Documentation for DarkRift {opts.Version} - {actualTier} (.NET {opts.Platform}) already installed! To force a reinstall use darkrift pull docs {opts.Version} -f"));
                    success = true;
                }
                else
                {
                    success = VersionManager.DownloadDocumentation(opts.Version);
                }
            }
            else
            {
                bool versionInstalled = VersionManager.IsVersionInstalled(opts.Version, actualTier, opts.Platform);
                if (versionInstalled && !opts.Force)
                {
                    Console.WriteLine(Output.Green($"DarkRift {opts.Version} - {actualTier} (.NET {opts.Platform}) already installed! To force a reinstall use darkrift pull {opts.Version} -f"));
                    success = true;
                }
                else
                {
                    success = VersionManager.DownloadVersion(opts.Version, actualTier, opts.Platform);
                }
            }

            if (!success)
            {
                Console.Error.WriteLine(Output.Red("Invalid command"));
                Console.Error.WriteLine("\t" + Environment.GetCommandLineArgs()[0] + " " + Parser.Default.FormatCommandLine(new PullOptions()));
                return(1);
            }

            return(0);
        }
        private int Pull(PullOptions opts)
        {
            // If --list was specified, list installed versions and tell if documentation for that version is available locally
            if (opts.List)
            {
                PrintInstalledVersions();
                return 0;
            }

            string version;
            ServerTier tier;
            string platform;
            if (opts.Version == null)
            {
                // If version info was omitted, set parameters to current project settings
                if (context.Project?.Runtime != null)
                {
                    version = context.Project.Runtime.Version;
                    platform = context.Project.Runtime.Platform;
                    tier = context.Project.Runtime.Tier;
                }
                else
                {
                    Console.Error.WriteLine(Output.Red($"Couldn't find a version to install. To download latest version use 'latest'"));
                    return 1;
                }
            }
            else
            {
                version = opts.Version == "latest" ? installationManager.GetLatestDarkRiftVersion() : opts.Version;
                tier = opts.Pro ? ServerTier.Pro : ServerTier.Free;
                platform = opts.Platform;
            }

            // If --docs was specified, download documentation instead
            if (opts.Docs)
            {
                bool docsInstalled = documentationManager.GetInstallation(version) != null;
                if (docsInstalled && !opts.Force)
                {
                    Console.WriteLine(Output.Green($"Documentation for DarkRift {version} - {tier} (.NET {platform}) already installed! To force a reinstall use the option -f or --force"));
                }
                else
                {
                    if (documentationManager.Install(version, opts.Force) == null)
                    {
                        Console.Error.WriteLine(Output.Red($"Could not install the requested documentation."));
                        return 1;
                    }
                }
            }
            else
            {
                bool versionInstalled = installationManager.GetInstallation(version, tier, platform) != null;
                if (versionInstalled && !opts.Force)
                {
                    Console.WriteLine(Output.Green($"DarkRift {version} - {tier} (.NET {platform}) already installed! To force a reinstall use the option -f or --force"));
                }
                else
                {
                    if (installationManager.Install(version, tier, platform, opts.Force) == null)
                    {
                        Console.Error.WriteLine(Output.Red($"Could not install the requested version."));
                        return 1;
                    }
                }
            }

            return 0;
        }