Skip to content
This repository has been 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 opened this issue Aug 5, 2017 · 0 comments
Open

Comments

@jamesqo
Copy link

jamesqo commented Aug 5, 2017

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.

ganchito55 added a commit to ganchito55/codeformatter that referenced this issue Oct 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant