Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Improve experience when the user passes --help, -help, -?, /?, or /help #264

Open
@jamesqo

Description

@jamesqo

I didn't read the README thoroughly and tried the above switches to get the usage. Each one of them generates an exception:

C:\cygwin64\home\james>CodeFormatter /?
?

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Invalid project file path: '/?'
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.ReportFailure(ReportMode mode, String message, Func`2 createException)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.TryGetAbsoluteProjectPath(String path, String baseDirectory, ReportMode mode, String& absolutePath)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenProjectAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at CodeFormatter.Program.<RunFormatItemAsync>d__4.MoveNext() in E:\codeformatter\src\CodeFormatter\Program.cs:line 135
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at CodeFormatter.Program.<RunFormatAsync>d__3.MoveNext() in E:\codeformatter\src\CodeFormatter\Program.cs:line 103
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(CancellationToken cancellationToken)
   at CodeFormatter.Program.RunFormat(CommandLineOptions options) in E:\codeformatter\src\CodeFormatter\Program.cs:line 76
   at CodeFormatter.Program.Main(String[] args) in E:\codeformatter\src\CodeFormatter\Program.cs:line 39
^CTerminate batch job (Y/N)? y

C:\cygwin64\home\james>CodeFormatter --help
--help

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Project file not found: 'C:\cygwin64\home\james\--help'
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.ReportFailure(ReportMode mode, String message, Func`2 createException)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.TryGetAbsoluteProjectPath(String path, String baseDirectory, ReportMode mode, String& absolutePath)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenProjectAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at CodeFormatter.Program.<RunFormatItemAsync>d__4.MoveNext() in E:\codeformatter\src\CodeFormatter\Program.cs:line 135
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at CodeFormatter.Program.<RunFormatAsync>d__3.MoveNext() in E:\codeformatter\src\CodeFormatter\Program.cs:line 103
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(CancellationToken cancellationToken)
   at CodeFormatter.Program.RunFormat(CommandLineOptions options) in E:\codeformatter\src\CodeFormatter\Program.cs:line 76
   at CodeFormatter.Program.Main(String[] args) in E:\codeformatter\src\CodeFormatter\Program.cs:line 39
^CTerminate batch job (Y/N)? y

C:\cygwin64\home\james>CodeFormatter -?
-?

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Invalid project file path: '-?'
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.ReportFailure(ReportMode mode, String message, Func`2 createException)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.TryGetAbsoluteProjectPath(String path, String baseDirectory, ReportMode mode, String& absolutePath)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenProjectAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at CodeFormatter.Program.<RunFormatItemAsync>d__4.MoveNext() in E:\codeformatter\src\CodeFormatter\Program.cs:line 135
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at CodeFormatter.Program.<RunFormatAsync>d__3.MoveNext() in E:\codeformatter\src\CodeFormatter\Program.cs:line 103
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(CancellationToken cancellationToken)
   at CodeFormatter.Program.RunFormat(CommandLineOptions options) in E:\codeformatter\src\CodeFormatter\Program.cs:line 76
   at CodeFormatter.Program.Main(String[] args) in E:\codeformatter\src\CodeFormatter\Program.cs:line 39
^CTerminate batch job (Y/N)? y

C:\cygwin64\home\james>CodeFormatter -help
-help

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Project file not found: 'C:\cygwin64\home\james\-help'
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.ReportFailure(ReportMode mode, String message, Func`2 createException)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.TryGetAbsoluteProjectPath(String path, String baseDirectory, ReportMode mode, String& absolutePath)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenProjectAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at CodeFormatter.Program.<RunFormatItemAsync>d__4.MoveNext() in E:\codeformatter\src\CodeFormatter\Program.cs:line 135
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at CodeFormatter.Program.<RunFormatAsync>d__3.MoveNext() in E:\codeformatter\src\CodeFormatter\Program.cs:line 103
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(CancellationToken cancellationToken)
   at CodeFormatter.Program.RunFormat(CommandLineOptions options) in E:\codeformatter\src\CodeFormatter\Program.cs:line 76
   at CodeFormatter.Program.Main(String[] args) in E:\codeformatter\src\CodeFormatter\Program.cs:line 39
^CTerminate batch job (Y/N)? y

C:\cygwin64\home\james>

Consider ignoring all other args and dumping the help if any of the args match /?, -?, -help, --help, or /help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions