Exemplo n.º 1
0
        private void ChocoListCommand_OnCommentUpdate(object sender, CommandUpdatedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(e.OutputLine))
            {
                return;
            }

            String[] parts = e.OutputLine.Split(' ');
            Version  ver;

            if (Version.TryParse(parts[1], out ver))
            {
                ListItem info = new ListItem();
                info.Name    = parts[0];
                info.Version = ver;
                if (parts.Length > 2 && parts[2] == "[Approved]")
                {
                    info.Approved = true;
                }
                if (parts.Length > 3)
                {
                    info.Comment = parts[3];
                }

                Output.Add(info);
                if (OnUpdate != null)
                {
                    ChocoListUpdateEventArgs args = new ChocoListUpdateEventArgs();
                    args.Program = info;
                    OnUpdate(this, args);
                }
            }
        }
Exemplo n.º 2
0
        private void P_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data == null)
            {
                return;
            }
            if (e.Data.StartsWith("Chocolatey v"))
            {
                ChocolateyVersion = Version.Parse(e.Data.Substring(12));
                if (ChocolateyVersion > CompatableChocoVersion)
                {
                    throw new NotSupportedException("");
                }
                return;
            }
            else if (InputRequestRegex.IsMatch(e.Data))
            {
                //Do you want to run the script?([Y]es/[N]o/[P]rint):
                Match m = InputRequestRegex.Match(e.Data);

                CommandInputNeededEventArgs ea = new CommandInputNeededEventArgs();
                ea.Message = m.Groups[1].Value;
                foreach (String option in m.Groups[2].Value.Split('/'))
                {
                    if (!InputOptionRegex.IsMatch(option))
                    {
                        throw new Exception("Input request option does not match expected pattern: " + option);
                    }

                    Match         om        = InputOptionRegex.Match(option);
                    String        character = om.Groups[2].Value;
                    StringBuilder text      = new StringBuilder();
                    for (int i = 1; i < om.Groups.Count; i++)
                    {
                        text.Append(om.Groups[i].Value);
                    }
                }
            }
            else
            {
                if (OnCommandUpdated != null)
                {
                    CommandUpdatedEventArgs args = new CommandUpdatedEventArgs();
                    args.OutputLine = e.Data;
                    OnCommandUpdated(this, args);
                }
            }
        }
Exemplo n.º 3
0
        private void ChocoOutdatedCommand_OnCommandUpdated(object sender, CommandUpdatedEventArgs e)
        {
            if (OutdatedOutputRegex.IsMatch(e.OutputLine))
            {
                Match       m    = OutdatedOutputRegex.Match(e.OutputLine);
                Outdatedtem info = new Outdatedtem();
                info.Name             = m.Groups[1].Value;
                info.InstalledVersion = Version.Parse(m.Groups[2].Value);
                info.LatestVersion    = Version.Parse(m.Groups[3].Value);
                info.Pinned           = Boolean.Parse(m.Groups[4].Value);

                if (OnUpdate != null)
                {
                    ChocoOutdatedUpdateEventArgs args = new ChocoOutdatedUpdateEventArgs();
                    args.Program = info;
                    OnUpdate(this, args);
                }
            }
        }
Exemplo n.º 4
0
 private void ChocoUpgradeCommand_OnCommandUpdated(object sender, CommandUpdatedEventArgs e)
 {
 }