`dotnet format` without arguments - show usage instead of stack trace
- Dominant language
- No language data
- Stars
- 1.9k
- Forks
- 173
- Avg merge
- 10d 13h
- Merged PRs (30d)
- 1
Description
Today I learned that `dotnet format` is included with .NET 6.0 SDK, so I ran `dotnet format`, hoping to find out which arguments it expects:
```cmd
> dotnet --version
6.0.100-rc.2.21505.57
> dotnet format
```
#### Observed results
Red stack trace text filled the console window, scrolling the point it was trying to make with the first line of output off the screen:
```cmd
> dotnet format
Unhandled exception: System.IO.FileNotFoundException: Could not find a MSBuild project file or solution file in 'C:\some\path'. Specify which to use with the argument.
at Microsoft.CodeAnalysis.Tools.Workspaces.MSBuildWorkspaceFinder.FindWorkspace(String searchDirectory, String workspacePath)
at Microsoft.CodeAnalysis.Tools.Workspaces.MSBuildWorkspaceFinder.FindWorkspace(String searchDirectory, String workspacePath)
at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.ParseWorkspaceOptions(ParseResult parseResult, FormatOptions formatOptions)
at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass27_0.<b__1>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__24_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<b__0>d.MoveNext()
```
#### Expected results
The tool should display some concise guidance for the user. Stack traces can be useful when there's an actual catastrophic error, but not so great for missing arguments.
It would be nice to see, for instance, just this (minus the stack trace):
```cmd
> dotnet format
Could not find a MSBuild project file or solution file in 'C:\some\path'.
Specify which to use with the argument.
```
Or perhaps to fall back to something like `dotnet format --help`:
```cmd
> dotnet format
Usage:
dotnet-format [options] [] [command]
Arguments:
directory for one. [default: C:\some\path\]
Options: [... etc ...]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.