示例#1
0
        public (Configuration configuration, string solutionPath) Get(string[] commandLineArguments)
        {
            var solutionFiles = _filesystem.FindSolutionFiles(".", false);

            if (1 != solutionFiles.Length)
            {
                _errors.Handle("Needs to be run from a directory with exactly one *.sln file in it.");
            }
            var solutionPath = Path.GetFullPath(solutionFiles.First());

            switch (ParseCommandLine(commandLineArguments))
            {
            case (_, HelpResult help):
                _console.Info(help.Text);
                _runtime.Abort(help.IsResultOfInvalidInput ? -1 : 0);
                break;

            case (var helpOverview, Configuration configuration):
                if (configuration.OldProjectName.Any(CommonExtensions.IsDirectorySeparator))
                {
                    _errors.Handle(
                        $"Do not specify paths for input/'old' project names, please.{Environment.NewLine}{Environment.NewLine}{helpOverview}");
                }

                configuration.OldProjectName = RemoveProjectFileExtension(configuration.OldProjectName);
                configuration.NewProjectName = RemoveProjectFileExtension(configuration.NewProjectName);

                return(configuration, solutionPath);

            default:
                _errors.Handle(
                    "Something went seriously wrong. Please create an issue at https://github.com/ModernRonin/ProjectRenamer with as much detail as possible.");
                break;
            }

            return(default);