Skip to content

Commit 08b3405

Browse files
Add 'fsi' between 'dotnet' and '--help' for fsi.exe (#9066)
* Add 'fsi' between 'dotnet' and '--help' for fsi.exe * Fix tests, make execution comparison case insensitive on windows Co-authored-by: Kevin Ransom <codecutter@hotmail.com>
1 parent a062a34 commit 08b3405

3 files changed

Lines changed: 27 additions & 13 deletions

File tree

src/fsharp/fsi/fsi.fs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,6 @@ let internal directoryName (s:string) =
586586
| res -> if res = "" then "." else res
587587

588588

589-
590-
591589
//----------------------------------------------------------------------------
592590
// cmd line - state for options
593591
//----------------------------------------------------------------------------
@@ -620,13 +618,29 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
620618
let isInteractiveServer() = fsiServerName <> ""
621619
let recordExplicitArg arg = explicitArgs <- explicitArgs @ [arg]
622620

623-
let executableFileName =
624-
lazy
625-
match tcConfigB.exename with
626-
| Some s -> s
627-
| None ->
628-
let currentProcess = System.Diagnostics.Process.GetCurrentProcess()
629-
Path.GetFileName(currentProcess.MainModule.FileName)
621+
let executableFileNameWithoutExtension =
622+
lazy
623+
let getFsiCommandLine () =
624+
let fileNameWithoutExtension path = Path.GetFileNameWithoutExtension(path)
625+
626+
let currentProcess = Process.GetCurrentProcess()
627+
let processFileName = fileNameWithoutExtension currentProcess.MainModule.FileName
628+
629+
let commandLineExecutableFileName =
630+
try fileNameWithoutExtension (Environment.GetCommandLineArgs().[0])
631+
with _ -> ""
632+
633+
let stringComparison =
634+
match Environment.OSVersion.Platform with
635+
| PlatformID.MacOSX
636+
| PlatformID.Unix -> StringComparison.Ordinal
637+
| _ -> StringComparison.OrdinalIgnoreCase
638+
639+
if String.Compare(processFileName, commandLineExecutableFileName, stringComparison) = 0
640+
then processFileName
641+
else sprintf "%s %s" processFileName commandLineExecutableFileName
642+
643+
tcConfigB.exename |> Option.defaultWith getFsiCommandLine
630644

631645

632646
// Additional fsi options are list below.
@@ -635,7 +649,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
635649
let displayHelpFsi tcConfigB (blocks:CompilerOptionBlock list) =
636650
DisplayBannerText tcConfigB;
637651
fprintfn fsiConsoleOutput.Out ""
638-
fprintfn fsiConsoleOutput.Out "%s" (FSIstrings.SR.fsiUsage(executableFileName.Value))
652+
fprintfn fsiConsoleOutput.Out "%s" (FSIstrings.SR.fsiUsage(executableFileNameWithoutExtension.Value))
639653
PrintCompilerOptionBlocks blocks
640654
exit 0
641655

@@ -761,7 +775,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
761775
fsiConsoleOutput.uprintfn "%s" (FSIstrings.SR.fsiBanner3())
762776

763777
member __.ShowHelp() =
764-
let helpLine = sprintf "%s --help" (Path.GetFileNameWithoutExtension executableFileName.Value)
778+
let helpLine = sprintf "%s --help" executableFileNameWithoutExtension.Value
765779

766780
fsiConsoleOutput.uprintfn ""
767781
fsiConsoleOutput.uprintfnn "%s" (FSIstrings.SR.fsiIntroTextHeader1directives());

tests/fsharpqa/Source/CompilerOptions/fsi/help/help40-nologo.437.1033.bsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
Usage: fsi.exe <options> [script.fsx [<arguments>]]
2+
Usage: fsiAnyCpu <options> [script.fsx [<arguments>]]
33

44

55
- INPUT FILES -

tests/fsharpqa/Source/CompilerOptions/fsi/help/help40.437.1033.bsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Microsoft (R) F# Interactive version 10.2.3 for F# 4.5
22
Copyright (c) Microsoft Corporation. All Rights Reserved.
33

4-
Usage: fsi.exe <options> [script.fsx [<arguments>]]
4+
Usage: fsiAnyCpu <options> [script.fsx [<arguments>]]
55

66

77
- INPUT FILES -

0 commit comments

Comments
 (0)