protected override string GetLogFilePathDefaultValue() { if (Directory.Exists(OeBuilderConstants.GetProjectDirectory(Directory.GetCurrentDirectory()))) { return(Path.Combine(OeBuilderConstants.GetProjectDirectoryLocal(Directory.GetCurrentDirectory()), "logs", "sakoe.log")); } return(Path.Combine(Directory.GetCurrentDirectory(), "sakoe.log")); }
protected override int ExecuteCommand(CommandLineApplication app, IConsole console) { if (string.IsNullOrEmpty(SourceDirectory)) { SourceDirectory = Directory.GetCurrentDirectory(); Log.Trace?.Write($"Using current directory to initialize the project: {SourceDirectory.PrettyQuote()}."); } SourceDirectory = SourceDirectory.ToAbsolutePath().ToCleanPath(); if (string.IsNullOrEmpty(ProjectName)) { ProjectName = Path.GetFileName(SourceDirectory); Log.Info($"Using directory name for the project name: {ProjectName.PrettyQuote()}."); } var projectDirectory = IsLocalProject ? OeBuilderConstants.GetProjectDirectoryLocal(SourceDirectory) : OeBuilderConstants.GetProjectDirectory(SourceDirectory); if (Utils.CreateDirectoryIfNeeded(projectDirectory, FileAttributes.Hidden)) { Log.Info($"Created project directory: {projectDirectory.PrettyQuote()}."); } Log.Trace?.Write("Generating a default project."); var project = OeProject.GetStandardProject(); var projectFilePath = Path.Combine(projectDirectory, $"{ProjectName}{OeBuilderConstants.OeProjectExtension}"); if (File.Exists(projectFilePath)) { if (Force) { File.Delete(projectFilePath); } else { throw new CommandValidationException($"The project file already exists, delete it first: {projectFilePath.PrettyQuote()}."); } } Log.Info($"Creating Openedge project file: {projectFilePath.PrettyQuote()}."); project.Save(projectFilePath); Log.Info($"Project created: {projectFilePath.PrettyQuote()}."); HelpWriter.WriteOnNewLine(null); HelpWriter.WriteSectionTitle("IMPORTANT README:"); HelpWriter.WriteOnNewLine(@" The project file created (" + OeBuilderConstants.OeProjectExtension + @") is defined in XML format and has a provided XML schema definition file (" + OeProject.XsdName + @"). The project XML schema is fully documented and should be used to enable intellisense in your favorite editor. Example of xml editors with out-of-the-box intellisense (autocomplete) features for xml: - Progress Developer studio (eclipse) - Visual studio - Most jetbrain IDE Drag and drop the created " + OeBuilderConstants.OeProjectExtension + @" file into the editor of your choice and start configuring your build. The file " + Path.Combine(OeBuilderConstants.GetProjectDirectory(""), $"{ProjectName}{OeBuilderConstants.OeProjectExtension}").PrettyQuote() + @" should be versioned in your source repository to allow anyone who clones your application to build it. The file " + OeProject.XsdName.PrettyQuote() + @", however, should not be versioned with your application because it depends on the version of this tool (sakoe). If this tool is updated, use the command " + typeof(ProjectUpdateCommand).GetFullCommandLine <MainCommand>().PrettyQuote() + @" to update the " + OeProject.XsdName.PrettyQuote() + @" to the latest version. If you need to have a project file containing build configurations specific to your local machine, you can use the option " + (GetCommandOptionFromPropertyName(nameof(IsLocalProject))?.Template ?? "").PrettyQuote() + @". This will create the project file into the directory " + OeBuilderConstants.GetProjectDirectoryLocal("").PrettyQuote() + @" which should NOT be versioned. For git repositories, use the command " + typeof(ProjectGitignoreCommand).GetFullCommandLine <MainCommand>().PrettyQuote() + @" to set up your .gitignore file for sakoe projects."); HelpWriter.WriteOnNewLine(null); return(0); }