Example #1
0
        public bool TryParse(CopyCommandOptions options)
        {
            var baseOptions = (CommonCopyCommandOptions)options;

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

            options = (CopyCommandOptions)baseOptions;

            if (!TryParseAsEnumFlags(Compare, OptionNames.Compare, out FileCompareOptions compareOptions, FileCompareOptions.None, OptionValueProviders.FileCompareOptionsProvider))
            {
                return(false);
            }

            if (!TryEnsureFullPath(Target, out string target))
            {
                return(false);
            }

            if (!TryParseAsEnum(OnConflict, OptionNames.Conflict, out ConflictResolution conflictResolution, defaultValue: ConflictResolution.Ask, provider: OptionValueProviders.ConflictResolutionProvider))
            {
                return(false);
            }

            options.CompareOptions     = compareOptions;
            options.DryRun             = DryRun;
            options.Flat               = Flat;
            options.ConflictResolution = conflictResolution;
            options.Target             = target;

            return(true);
        }
Example #2
0
 internal static void WriteCopyCommand(CopyCommandOptions options)
 {
     WriteOption("ask", options.AskMode);
     WriteOption("attributes", options.Attributes);
     WriteOption("attributes to skip", options.AttributesToSkip);
     WriteOption("compare", options.CompareOptions);
     WriteOption("conflict resolution", options.ConflictResolution);
     WriteFilter("content filter", options.ContentFilter);
     WriteEncoding("default encoding", options.DefaultEncoding);
     WriteFilter("directory filter", options.DirectoryFilter, options.DirectoryNamePart);
     WriteDisplayFormat("display", options.Format);
     WriteOption("dry run", options.DryRun);
     WriteOption("empty", options.EmptyOption);
     WriteFilter("extension filter", options.ExtensionFilter);
     WriteFilePropertyFilter(
         "file properties",
         options.SizePredicate,
         options.CreationTimePredicate,
         options.ModifiedTimePredicate);
     WriteOption("flat", options.Flat);
     WriteOption("highlight options", options.HighlightOptions);
     WriteOption("max matching files", options.MaxMatchingFiles);
     WriteOption("max matches in file", options.MaxMatchesInFile);
     WriteFilter("name filter", options.NameFilter, options.NamePart);
     WritePaths("paths", options.Paths);
     WriteOption("progress", options.Progress);
     WriteOption("recurse subdirectories", options.RecurseSubdirectories);
     WriteOption("search target", options.SearchTarget);
     WriteSortOptions("sort", options.SortOptions);
     WriteOption("target", options.Target);
 }
Example #3
0
        private static int Copy(CopyCommandLineOptions commandLineOptions)
        {
            var options = new CopyCommandOptions();

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

            return(Execute(new CopyCommand(options)));
        }
Example #4
0
        public bool TryParse(CopyCommandOptions options)
        {
            var baseOptions = (CommonCopyCommandOptions)options;

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

            options = (CopyCommandOptions)baseOptions;

            if (!TryParseAsEnumFlags(
                    Compare,
                    OptionNames.Compare,
                    out FileCompareOptions compareOptions,
                    FileCompareOptions.None,
                    OptionValueProviders.FileCompareOptionsProvider))
            {
                return(false);
            }

            if (!TryParseTargetDirectory(Target, out string?target, options, nameof(Target), OptionNames.Target))
            {
                return(false);
            }

            if (!TryParseAsEnum(
                    Conflict,
                    OptionNames.Conflict,
                    out ConflictResolution conflictResolution,
                    defaultValue: ConflictResolution.Ask,
                    provider: OptionValueProviders.ConflictResolutionProvider))
            {
                return(false);
            }

            options.CompareOptions     = compareOptions;
            options.DryRun             = DryRun;
            options.Flat               = Flat;
            options.ConflictResolution = conflictResolution;
            options.Target             = target;
            options.AskMode            = (Ask) ? AskMode.File : AskMode.None;

            return(true);
        }