예제 #1
0
        public bool TryParse(SplitCommandOptions options)
        {
            var baseOptions = (RegexCommandOptions)options;

            if (!TryParse(baseOptions))
            {
                return(false);
            }

            options = (SplitCommandOptions)baseOptions;

            if (!FilterParser.TryParse(Content, OptionNames.Content, OptionValueProviders.PatternOptionsWithoutGroupAndPartAndNegativeProvider, out Filter filter))
            {
                return(false);
            }

            if (!TryParseAsEnumFlags(Highlight, OptionNames.Highlight, out HighlightOptions highlightOptions, defaultValue: HighlightOptions.Split, provider: OptionValueProviders.SplitHighlightOptionsProvider))
            {
                return(false);
            }

            options.Filter           = filter;
            options.HighlightOptions = highlightOptions;
            options.OmitGroups       = NoGroups;
            options.MaxCount         = MaxCount;

            return(true);
        }
예제 #2
0
 internal static void WriteSplitCommand(SplitCommandOptions options)
 {
     WriteDisplayFormat("display", options.Format);
     WriteFilter("filter", options.Filter);
     WriteOption("highlight options", options.HighlightOptions);
     WriteInput(options.Input);
     WriteOption("max count", options.MaxCount);
     WriteOption("omit groups", options.OmitGroups);
 }
예제 #3
0
        private static int Split(SplitCommandLineOptions commandLineOptions)
        {
            var options = new SplitCommandOptions();

            if (!commandLineOptions.TryParse(options))
            {
                return(2);
            }

            return(Execute(new SplitCommand(options)));
        }