Repository navigation
Open
Description
I'm using Nuke to implement various pipelines.
I added dotnet format (see nuke-build/nuke#1032), which is already released with the latest version.
Nuke handle verbosity for dotnet with the enum DotNetVerbosity.
public partial class DotNetVerbosity : Enumeration
{
public static DotNetVerbosity Quiet = (DotNetVerbosity) "Quiet";
public static DotNetVerbosity Minimal = (DotNetVerbosity) "Minimal";
public static DotNetVerbosity Normal = (DotNetVerbosity) "Normal";
public static DotNetVerbosity Detailed = (DotNetVerbosity) "Detailed";
public static DotNetVerbosity Diagnostic = (DotNetVerbosity) "Diagnostic";
public static implicit operator DotNetVerbosity(string value)
{
return new DotNetVerbosity { Value = value };
}
}This enum is now also used for dotnet format. All dotnet commands which I use (clean, restore, compile, pack) can handle verbosity with capitalized value except format.
Console Output:
C:\projects\format_test>dotnet clean FormatTest.sln --verbosity Quiet
MSBuild version 17.4.0+18d5aef85 for .NET
C:\projects\format_test>dotnet restore FormatTest.sln --verbosity Quiet
C:\projects\format_test>dotnet build FormatTest.sln --verbosity Quiet
MSBuild version 17.4.0+18d5aef85 for .NET
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.46
C:\projects\format_test>dotnet pack FormatTest.sln --verbosity Quiet
MSBuild version 17.4.0+18d5aef85 for .NET
C:\projects\format_test>dotnet format FormatTest.sln --verbosity Quiet --verify-no-changes
Argument 'Quiet' not recognized. Must be one of:
'q'
'quiet'
'm'
'minimal'
'n'
'normal'
'd'
'detailed'
'diag'
'diagnostic'
Description:
Formats code to match editorconfig settings.
Usage:
dotnet-format [<The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.>] [command] [options]
Arguments:
<The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.> The project or solution file to operate on. If a file is not specified, the command will search the current directory for one. [default: C:\projects\format_test\]
Options:
--diagnostics <diagnostics> A space separated list of diagnostic ids to use as a filter when fixing code style or 3rd party issues. []
--exclude-diagnostics <exclude-diagnostics> A space separated list of diagnostic ids to ignore when fixing code style or 3rd party issues. []
--severity <error|info|warn> The severity of diagnostics to fix. Allowed values are info, warn, and error.
--no-restore Doesn't execute an implicit restore before formatting.
--verify-no-changes Verify no formatting changes would be performed. Terminates with a non-zero exit code if any files would have been formatted.
--include <include> A list of relative file or folder paths to include in formatting. All files are formatted if empty. []
--exclude <exclude> A list of relative file or folder paths to exclude from formatting. []
--include-generated Format files generated by the SDK.
-v, --verbosity <d|detailed|diag|diagnostic|m|minimal|n|normal|q|quiet> Set the verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]
--binarylog <binary-log-path> Log all project or solution load information to a binary log file.
--report <report-path> Accepts a file path which if provided will produce a json report in the given directory.
--version Show version information
-?, -h, --help Show help and usage information
Commands:
whitespace <The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.> Run whitespace formatting. [default: C:\projects\format_test\]
style <The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.> Run code style analyzers and apply fixes. [default: C:\projects\format_test\]
analyzers <The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.> Run 3rd party analyzers and apply fixes. [default: C:\projects\format_test\]
C:\projects\format_test>
Would be really useful when dotnet format supports also capitalized verbosity values like Quiet, Minimal, ... and it would be consistent to other dotnet commands.
Metadata
Metadata
Assignees
Labels
No labels
Activity
sharwell commentedon Jul 25, 2023
@adamsitnik Can you weigh in on this?
adamsitnik commentedon Jul 27, 2023
System.CommandLine (the parser) ignores case by default when parsing
Enums:https://github.com/dotnet/command-line-api/blob/6c8c9b06e56e4c09c33942f62eb5ad4a9c9ca445/src/System.CommandLine/Binding/ArgumentConverter.cs#L57-L64
But dotnet/format asks it explicitly to accept only values from the provided list:
format/src/Commands/FormatCommandCommon.cs
Line 99 in df983b3
And in such case it's rejected here:
https://github.com/dotnet/command-line-api/blob/6c8c9b06e56e4c09c33942f62eb5ad4a9c9ca445/src/System.CommandLine/Argument%7BT%7D.cs#L109-L111
@jonsequitur should we just add
bool ignoreCase = falsetoAcceptOnlyFromAmong?jonsequitur commentedon Jul 27, 2023
That would probably make sense.
adamsitnik commentedon Jul 31, 2023
I've created a new issue: dotnet/command-line-api#2254