예제 #1
0
        private static ExitCode LoadSubthemeConfig(SubthemeArgsOptions options, out SubthemeOptions config)
        {
            config = new SubthemeOptions();

            string directory = options?.ThemePath;

            config.Theme = string.IsNullOrEmpty(directory)
                ? InputHelpers.AskForDirectory("Enter the full path of the base theme:")
                : InputHelpers.GetDirectory(directory);

            if (config.Theme == null)
            {
                return(ExitCode.InvalidSourceDirectory);
            }

            directory = options?.SubthemePath;

            config.Subtheme = string.IsNullOrEmpty(directory)
                ? InputHelpers.AskForDirectory("Enter the full path of the subtheme:", false)
                : InputHelpers.GetDirectory(directory, false);

            if (config.Subtheme == null)
            {
                return(ExitCode.InvalidDestinationDirectory);
            }

            if (string.Equals(config.Theme.FullName, config.Subtheme.FullName, StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine();

                "Subtheme directory cannot be the same as the theme directory.".WriteLineRed();

                return(ExitCode.InvalidDestinationDirectory);
            }

            return(ExitCode.Success);
        }
예제 #2
0
        private static ExitCode LoadCopyConfig(CopyArgsOptions options, out CopyOptions config)
        {
            config = new CopyOptions();

            string directory = options?.SourceDirectory;

            config.Source = string.IsNullOrEmpty(directory)
                ? InputHelpers.AskForDirectory("Enter the full path of the source directory:")
                : InputHelpers.GetDirectory(directory);

            if (config.Source == null)
            {
                return(ExitCode.InvalidSourceDirectory);
            }

            directory = options?.DestDirectory;

            config.Dest = string.IsNullOrEmpty(directory)
                ? InputHelpers.AskForDirectory("Enter the full path of the destination directory:")
                : InputHelpers.GetDirectory(directory);

            if (config.Dest == null)
            {
                return(ExitCode.InvalidDestinationDirectory);
            }

            if (string.Equals(config.Source.FullName, config.Dest.FullName, StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine();

                "Destination directory cannot be the same as the source directory.".WriteLineRed();

                return(ExitCode.InvalidDestinationDirectory);
            }

            config.MachineNameFilter = options == null
                ? InputHelpers.AskAnyAnswer(
                "Enter machine name filter, or just empty line if you don't need machine name filtering:")
                : options.MachineNameFilter;

            config.FileNameFilter = options == null
                ? InputHelpers.AskAnyAnswer(
                "Enter file name filter, or just empty line if you don't need file name filtering:")
                : options.FileNameFilter;

            config.Override = options?.Override ??
                              InputHelpers.AskYesNo("Should files from the destination directory be overridden?");

            //if (options == null)
            //    config.SiteUuid =
            //        AskForSiteUuid(
            //            "Enter a backup site UUID that will be used if the UUID cannot be inferred, or just empty line if it isn't needed:");
            //else if (!string.IsNullOrEmpty(options.SiteUuid))
            //{
            //    if (Guid.TryParse(options.SiteUuid, out Guid uuid))
            //        config.SiteUuid = uuid;
            //    else
            //    {
            //        $"Value '{options.SiteUuid}' doesn't have a valid UUID format.".WriteLineRed();

            //        return ExitCode.InvalidArguments;
            //    }
            //}

            return(ExitCode.Success);
        }