Esempio n. 1
0
            /// <summary>
            /// Performs all necessary queries to determine whether any violations were found, returning all violation objects as <see cref="CommandLineViolation"/>.
            /// </summary>
            /// <returns>
            /// Returns a collection of <see cref="CommandLineViolation"/> representing the violations, if any violations where found.
            /// Returns an empty collection if no violations were found.
            /// </returns>
            public override IEnumerable <CommandLineViolation> GetViolations()
            {
                IEnumerable <string> rootArgs = CommandLine.Arguments.Where(str => str.StartsWith(RootSpecification.Delimiter));
                IEnumerable <ICommandLineArgument> rootICLAs   = KnownArguments.Where(icla => rootArgs.Contains(icla.Command));
                IEnumerable <string>         workingCollection = CommandLine.ExcludeParams(CommandLine.Arguments, KnownSpecifications);
                List <IEnumerable <string> > rootSegments      = new List <IEnumerable <string> >();

                foreach (ICommandLineArgument rootArg in rootICLAs)
                {
                    var segment = rootArg.GetSegment(null, workingCollection);

                    if (segment.Any())
                    {
                        rootSegments.Add(segment);
                        workingCollection = workingCollection.ExcludeSubset(segment);
                    }
                }

                foreach (ICommandLineGrouping grouping in LegalCombinations)
                {
                    IEnumerable <string> groupCommands = grouping.ParentCallChain.Select(pa => pa.Command)
                                                         .Concat(grouping.Children.Select(child => child.Command));

                    foreach (IEnumerable <string> rootSegment in rootSegments)
                    {
                        IEnumerable <string> rootSeg = rootSegment;

                        if (groupCommands.UnorderedSequenceEquals(rootSeg))
                        {
                            rootSegments.Remove(rootSegment);
                            break;
                        }
                    }
                }

                if (rootSegments.Any())
                {
                    foreach (IEnumerable <string> rootSegment in rootSegments)
                    {
                        yield return new CommandLineViolation()
                               {
                                   Violation = nameof(LegalArgumentsRestriction), Message = string.Join(" ", rootSegment)
                               }
                    }
                }
                ;
            }
Esempio n. 2
0
 public void Mainline(int number) => AddArgument(KnownArguments.Mainline(number));
Esempio n. 3
0
 /// <summary>
 /// Performs all necessary queries to determine whether any violations were found, returning all violation objects as <see cref="CommandLineViolation"/>.
 /// </summary>
 /// <returns>
 /// Returns a collection of <see cref="CommandLineViolation"/> representing the violations, if any violations where found.
 /// Returns an empty collection if no violations were found.
 /// </returns>
 public override IEnumerable <CommandLineViolation> GetViolations()
 {
     if (CommandLine.Arguments.Any())
     {
         var unknownArgs = CommandLine.ExcludeParams(CommandLine.Arguments, KnownSpecifications).Except(KnownArguments.Select(icla => icla.Command));
         if (unknownArgs.Any())
         {
             foreach (string unknownArg in unknownArgs)
             {
                 yield return new CommandLineViolation()
                        {
                            Violation = nameof(UnknownArgumentsRestriction), Message = unknownArg
                        }
             }
         }
         ;
     }
 }
Esempio n. 4
0
 public void NoMerged(string commit = null) => AddArgument(KnownArguments.NoMerged(commit));
Esempio n. 5
0
 public void NoContains(string commit = null) => AddArgument(KnownArguments.NoContains(commit));
Esempio n. 6
0
 public void Abbrev(int length = 7) => AddArgument(KnownArguments.Abbrev(length));
Esempio n. 7
0
 public void Color(BranchColorWhen when = BranchColorWhen.Always) => AddArgument(KnownArguments.Color(when));