diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 950d46ed..bebfe5a3 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +### 6.2.2 +* Fix default `programName` when invoking via a wrapper such as `dotnet.exe` [#233](https://github.com/fsprojects/Argu/pull/233) + ### 6.2.1 * Fix `ParseResults.ProgramName` - make it public (cut and paste error in [#229](https://github.com/fsprojects/Argu/pull/229)) [#231](https://github.com/fsprojects/Argu/pull/231) diff --git a/src/Argu/ArgumentParser.fs b/src/Argu/ArgumentParser.fs index ebf693d2..cfc3ce47 100644 --- a/src/Argu/ArgumentParser.fs +++ b/src/Argu/ArgumentParser.fs @@ -99,7 +99,7 @@ and [] /// /// Creates a new parser instance based on supplied F# union template. /// - /// Program identifier, e.g. 'cat'. Defaults to the current executable name. + /// Program identifier, e.g. 'cat'. Defaults to the current running executable per Assembly.GetEntryAssembly(). /// Message that will be displayed at the top of the help text. /// Text width used when formatting the usage string. Defaults to 80 chars. /// The implementation of IExiter used for error handling. Exception is default. diff --git a/src/Argu/Utils.fs b/src/Argu/Utils.fs index f530d9a6..80c3bfb9 100644 --- a/src/Argu/Utils.fs +++ b/src/Argu/Utils.fs @@ -135,7 +135,10 @@ type IDictionary<'K,'V> with if ok then Some found else None -let currentProgramName = lazy System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName +// NOTE: Prior to 6.2.2, this was System.Diagnostics.Process.GetCurrentProcess() +// That previous approach derives `dotnet` when you `dotnet run` a program +// (or you invoke via `dotnet tool run` and/or if your IDE wraps the invocation etc) +let currentProgramName = lazy Assembly.GetEntryAssembly().GetName().Name /// recognize exprs that strictly contain DU constructors /// e.g. <@ Case @> is valid but <@ fun x y -> Case y x @> is invalid @@ -353,4 +356,4 @@ let wordwrap (width:int) (inputText:string) = pos <- next - lines.ToArray() |> Array.toList \ No newline at end of file + lines.ToArray() |> Array.toList