codeformatter icon indicating copy to clipboard operation
codeformatter copied to clipboard

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

Open jamesqo opened this issue 8 years ago • 0 comments

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.

jamesqo avatar Aug 05 '17 03:08 jamesqo