Пример #1
0
        /// <inheritdoc />
        protected override int Execute(IInput input, IOutput output)
        {
            var bucket = GetBucket(true, input.GetOption("no-plugins"));

            string[] packages = input.GetArgument("packages") ?? Array.Empty <string>();

            packages = ProcessRootRequires(bucket.GetPackage(), input, packages);

            // todo: set no-progress.
            // todo: add gui interactive select the packages.
            var commandEvent = new CommandEventArgs(PluginEvents.Command, "update", input, output);

            bucket.GetEventDispatcher().Dispatch(this, commandEvent);

            var io        = GetIO();
            var installer = new BucketInstaller(io, bucket);

            var config = bucket.GetConfig();

            var(preferSource, preferDist) = GetPreferredInstallOptions(config, input);

            ISet <string> GetUpdateWhitlist()
            {
                if (input.GetOption("lock"))
                {
                    return(new HashSet <string>(new[] { "lock" }));
                }

                return(packages.Empty() ? null : new HashSet <string>(packages));
            }

            installer.SetDryRun(input.GetOption("dry-run"))
            .SetVerbose(input.GetOption("verbose"))
            .SetPreferSource(preferSource)
            .SetPreferDist(preferDist)
            .SetDevMode(!input.GetOption("no-dev"))
            .SetRunScripts(!input.GetOption("no-scripts"))
            .SetSkipSuggest(input.GetOption("no-suggest"))
            .SetIgnorePlatformRequirements(input.GetOption("ignore-platform-reqs"))
            .SetUpdate(true)
            .SetUpdateWhitelist(GetUpdateWhitlist())
            .SetWhitelistAllDependencies(input.GetOption("with-all-dependencies"))
            .SetWhitelistTransitiveDependencies(input.GetOption("with-dependencies"))
            .SetPreferStable(input.GetOption("prefer-stable"))
            .SetPreferLowest(input.GetOption("prefer-lowest"));

            if (input.GetOption("no-plugins"))
            {
                installer.DisablePlugins();
            }

            return(installer.Run());
        }
Пример #2
0
        /// <inheritdoc />
        protected override int Execute(IInput input, IOutput output)
        {
            var io = GetIO();

            string[] args = input.GetArgument("packages");
            if (!args.Empty())
            {
                io.WriteError($"<error>Invalid argument {string.Join(Str.Space, args)}. Use \"bucket require {string.Join(Str.Space, args)}\" instead to add packages to your bucket.json.</error>");
                return(ExitCodes.GeneralException);
            }

            var bucket = GetBucket(true, input.GetOption("no-plugins"));

            // todo: set no-progress.
            var commandEvent = new CommandEventArgs(PluginEvents.Command, "install", input, output);

            bucket.GetEventDispatcher().Dispatch(this, commandEvent);

            var installer = new BucketInstaller(io, bucket);

            var config = bucket.GetConfig();

            var(preferSource, preferDist) = GetPreferredInstallOptions(config, input);

            installer.SetDryRun(input.GetOption("dry-run"))
            .SetVerbose(input.GetOption("verbose"))
            .SetPreferSource(preferSource)
            .SetPreferDist(preferDist)
            .SetDevMode(!input.GetOption("no-dev"))
            .SetRunScripts(!input.GetOption("no-scripts"))
            .SetSkipSuggest(input.GetOption("no-suggest"))
            .SetIgnorePlatformRequirements(input.GetOption("ignore-platform-reqs"));

            if (input.GetOption("no-plugins"))
            {
                installer.DisablePlugins();
            }

            return(installer.Run());
        }