-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from microsoft/dev/sknam/add-commandline-parser
Add the command line parser and parse the tool arguments
- Loading branch information
Showing
17 changed files
with
63 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
namespace VSConfigFinder | ||
{ | ||
internal class CommandLineOptions : ICommandLineOptions | ||
{ | ||
public CommandLineOptions(string filePath, string output) | ||
{ | ||
Utilities.ValidateIsNotNullOrEmpty(filePath, nameof(filePath)); | ||
Utilities.ValidateOutputParameter(output, nameof(output)); | ||
|
||
FilePath = filePath; | ||
Output = output; | ||
} | ||
using CommandLine; | ||
|
||
public string FilePath { get; set; } | ||
/// <inheritdoc/> | ||
public class CommandLineOptions : ICommandLineOptions | ||
{ | ||
/// <inheritdoc/> | ||
[Option("folderpath", Required = true, HelpText = "Set the source folder path to use as the root. The search will start from the root towards the bottom.")] | ||
public string FolderPath { get; set; } | ||
|
||
public string Output { get; set; } | ||
/// <inheritdoc/> | ||
[Option("createfile", Required = false, HelpText = "Set the folder path to output the consolidated .vsconfig.\n" + | ||
"If the argument (--createfile) is not passed at all, the program will output the cli arguments that can be fed into the Visual Studio Installer setup arguments. (e.g. --add Microsoft.VisualStudio.Component.Roslyn.Compiler Microsoft.Net.Component.4.8.SDK)\n" + | ||
"If the argument is passed without a following folder path, the program will create and output the final .vsconfig into the current directory.\n" + | ||
"If the argument is passed with a following folder path, the program will create and output the final .vsconfig into the specified folder path that is followed by --createFile.")] | ||
public string? CreateFile { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
namespace VSConfigFinder | ||
{ | ||
internal interface ICommandLineOptions | ||
/// <summary> | ||
/// The interface for the command line options. | ||
/// </summary> | ||
public interface ICommandLineOptions | ||
{ | ||
string FilePath { get; set; } | ||
/// <summary> | ||
/// Gets or sets the folder path to be used as the root (starting point) of the search. | ||
/// </summary> | ||
string FolderPath { get; set; } | ||
|
||
string Output { get; set; } | ||
/// <summary> | ||
/// Gets or sets the folder path to output the consolidated .vsconfig instead of the command line arguments. | ||
/// If a folder path is not provided after the argument, the output folder will default to the current directory. | ||
/// </summary> | ||
string? CreateFile { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,38 @@ | ||
internal class Program | ||
namespace VSConfigFinder | ||
{ | ||
private static void Main(string[] args) | ||
using CommandLine; | ||
|
||
/// <summary> | ||
/// <see cref="Program"/> class for the .vsconfig finder tool. | ||
/// </summary> | ||
public class Program | ||
{ | ||
// Take in the command line arguments | ||
/// <summary> | ||
/// Main entry point of the tool. | ||
/// </summary> | ||
/// <param name="args">The program arguments</param> | ||
public static void Main(string[] args) | ||
{ | ||
var parser = new Parser(with => | ||
{ | ||
with.CaseSensitive = false; | ||
}); | ||
|
||
// Take in the command line arguments | ||
parser.ParseArguments<CommandLineOptions>(args) | ||
.WithParsed(Run) | ||
.WithNotParsed(HandleParseError); | ||
} | ||
|
||
// Create a runner | ||
private static void Run(CommandLineOptions options) | ||
{ | ||
Console.WriteLine("Hello! I succeeded!"); | ||
Console.WriteLine($"--createFile: {options.CreateFile}"); | ||
} | ||
|
||
// Run and output | ||
private static void HandleParseError(IEnumerable<Error> errors) | ||
{ | ||
Console.WriteLine("Oops, failed"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
VSConfigFinder/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
VSConfigFinder/obj/Debug/net7.0/VSConfigFinder.AssemblyInfo.cs
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
VSConfigFinder/obj/Debug/net7.0/VSConfigFinder.AssemblyInfoInputs.cache
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
VSConfigFinder/obj/Debug/net7.0/VSConfigFinder.GeneratedMSBuildEditorConfig.editorconfig
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
VSConfigFinder/obj/Debug/net7.0/VSConfigFinder.GlobalUsings.g.cs
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file removed
BIN
-91.1 KB
VSConfigFinder/obj/Debug/net7.0/VSConfigFinder.csproj.AssemblyReference.cache
Binary file not shown.
64 changes: 0 additions & 64 deletions
64
VSConfigFinder/obj/VSConfigFinder.csproj.nuget.dgspec.json
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.