11using System . CommandLine ;
2+ using Microsoft . Extensions . Logging ;
23
34namespace CSharpier . Cli ;
45
5- using Microsoft . Extensions . Logging ;
6-
76internal class CommandLineOptions
87{
9- public string [ ] DirectoryOrFilePaths { get ; init ; } = Array . Empty < string > ( ) ;
8+ public string [ ] DirectoryOrFilePaths { get ; init ; } = [ ] ;
109 public bool Check { get ; init ; }
1110 public bool Fast { get ; init ; }
1211 public bool SkipWrite { get ; init ; }
@@ -17,7 +16,7 @@ internal class CommandLineOptions
1716 public bool IncludeGenerated { get ; init ; }
1817 public string ? StandardInFileContents { get ; init ; }
1918 public string ? ConfigPath { get ; init ; }
20- public string [ ] OriginalDirectoryOrFilePaths { get ; init ; } = Array . Empty < string > ( ) ;
19+ public string [ ] OriginalDirectoryOrFilePaths { get ; init ; } = [ ] ;
2120
2221 internal delegate Task < int > Handler (
2322 string [ ] directoryOrFile ,
@@ -47,57 +46,48 @@ public static RootCommand Create()
4746 Description =
4847 "One or more paths to a directory containing C# files to format or a C# file to format. It may be ommited when piping data via stdin." ,
4948 } . LegalFilePathsOnly ( ) ,
50- new Option (
51- new [ ] { "--check" } ,
52- "Check that files are formatted. Will not write any changes."
53- ) ,
49+ new Option ( [ "--check" ] , "Check that files are formatted. Will not write any changes." ) ,
5450 new Option < string > (
55- new [ ] { "--loglevel" } ,
51+ [ "--loglevel" ] ,
5652 ( ) => LogLevel . Information . ToString ( ) ,
5753 "Specify the log level - Debug, Information (default), Warning, Error, None"
5854 ) ,
5955 new Option (
60- new [ ] { "--no-cache" } ,
56+ [ "--no-cache" ] ,
6157 "Bypass the cache to determine if a file needs to be formatted."
6258 ) ,
6359 new Option (
64- new [ ] { "--no-msbuild-check" } ,
60+ [ "--no-msbuild-check" ] ,
6561 "Bypass the check to determine if a csproj files references a different version of CSharpier.MsBuild."
6662 ) ,
6763 new Option (
68- new [ ] { "--include-generated" } ,
64+ [ "--include-generated" ] ,
6965 "Include files generated by the SDK and files that begin with <autogenerated /> comments"
7066 ) ,
7167 new Option (
72- new [ ] { "--fast" } ,
68+ [ "--fast" ] ,
7369 "Skip comparing syntax tree of formatted file to original file to validate changes."
7470 ) ,
7571 new Option (
76- new [ ] { "--skip-write" } ,
72+ [ "--skip-write" ] ,
7773 "Skip writing changes. Generally used for testing to ensure csharpier doesn't throw any errors or cause syntax tree validation failures."
7874 ) ,
75+ new Option ( [ "--write-stdout" ] , "Write the results of formatting any files to stdout." ) ,
7976 new Option (
80- new [ ] { "--write-stdout" } ,
81- "Write the results of formatting any files to stdout."
82- ) ,
83- new Option (
84- new [ ] { "--pipe-multiple-files" } ,
77+ [ "--pipe-multiple-files" ] ,
8578 "Keep csharpier running so that multiples files can be piped to it via stdin."
8679 ) ,
8780 new Option (
88- new [ ] { "--server" } ,
81+ [ "--server" ] ,
8982 "Run CSharpier as a server so that multiple files may be formatted."
9083 ) ,
9184 new Option < int ? > (
92- new [ ] { "--server-port" } ,
85+ [ "--server-port" ] ,
9386 "Specify the port that CSharpier should start on. Defaults to a random unused port."
9487 ) ,
95- new Option < string > (
96- new [ ] { "--config-path" } ,
97- "Path to the CSharpier configuration file"
98- ) ,
88+ new Option < string > ( [ "--config-path" ] , "Path to the CSharpier configuration file" ) ,
9989 new Option (
100- new [ ] { "--compilation-errors-as-warnings" } ,
90+ [ "--compilation-errors-as-warnings" ] ,
10191 "Treat compilation errors from files as warnings instead of errors."
10292 ) ,
10393 } ;
0 commit comments