1
1
using System . CommandLine ;
2
+ using Microsoft . Extensions . Logging ;
2
3
3
4
namespace CSharpier . Cli ;
4
5
5
- using Microsoft . Extensions . Logging ;
6
-
7
6
internal class CommandLineOptions
8
7
{
9
- public string [ ] DirectoryOrFilePaths { get ; init ; } = Array . Empty < string > ( ) ;
8
+ public string [ ] DirectoryOrFilePaths { get ; init ; } = [ ] ;
10
9
public bool Check { get ; init ; }
11
10
public bool Fast { get ; init ; }
12
11
public bool SkipWrite { get ; init ; }
@@ -17,7 +16,7 @@ internal class CommandLineOptions
17
16
public bool IncludeGenerated { get ; init ; }
18
17
public string ? StandardInFileContents { get ; init ; }
19
18
public string ? ConfigPath { get ; init ; }
20
- public string [ ] OriginalDirectoryOrFilePaths { get ; init ; } = Array . Empty < string > ( ) ;
19
+ public string [ ] OriginalDirectoryOrFilePaths { get ; init ; } = [ ] ;
21
20
22
21
internal delegate Task < int > Handler (
23
22
string [ ] directoryOrFile ,
@@ -47,57 +46,48 @@ public static RootCommand Create()
47
46
Description =
48
47
"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." ,
49
48
} . 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." ) ,
54
50
new Option < string > (
55
- new [ ] { "--loglevel" } ,
51
+ [ "--loglevel" ] ,
56
52
( ) => LogLevel . Information . ToString ( ) ,
57
53
"Specify the log level - Debug, Information (default), Warning, Error, None"
58
54
) ,
59
55
new Option (
60
- new [ ] { "--no-cache" } ,
56
+ [ "--no-cache" ] ,
61
57
"Bypass the cache to determine if a file needs to be formatted."
62
58
) ,
63
59
new Option (
64
- new [ ] { "--no-msbuild-check" } ,
60
+ [ "--no-msbuild-check" ] ,
65
61
"Bypass the check to determine if a csproj files references a different version of CSharpier.MsBuild."
66
62
) ,
67
63
new Option (
68
- new [ ] { "--include-generated" } ,
64
+ [ "--include-generated" ] ,
69
65
"Include files generated by the SDK and files that begin with <autogenerated /> comments"
70
66
) ,
71
67
new Option (
72
- new [ ] { "--fast" } ,
68
+ [ "--fast" ] ,
73
69
"Skip comparing syntax tree of formatted file to original file to validate changes."
74
70
) ,
75
71
new Option (
76
- new [ ] { "--skip-write" } ,
72
+ [ "--skip-write" ] ,
77
73
"Skip writing changes. Generally used for testing to ensure csharpier doesn't throw any errors or cause syntax tree validation failures."
78
74
) ,
75
+ new Option ( [ "--write-stdout" ] , "Write the results of formatting any files to stdout." ) ,
79
76
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" ] ,
85
78
"Keep csharpier running so that multiples files can be piped to it via stdin."
86
79
) ,
87
80
new Option (
88
- new [ ] { "--server" } ,
81
+ [ "--server" ] ,
89
82
"Run CSharpier as a server so that multiple files may be formatted."
90
83
) ,
91
84
new Option < int ? > (
92
- new [ ] { "--server-port" } ,
85
+ [ "--server-port" ] ,
93
86
"Specify the port that CSharpier should start on. Defaults to a random unused port."
94
87
) ,
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" ) ,
99
89
new Option (
100
- new [ ] { "--compilation-errors-as-warnings" } ,
90
+ [ "--compilation-errors-as-warnings" ] ,
101
91
"Treat compilation errors from files as warnings instead of errors."
102
92
) ,
103
93
} ;
0 commit comments