You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn about the command-line options supported by F# Interactive, fsi.exe.
4
-
ms.date: 05/16/2016
4
+
ms.date: 07/22/2020
5
5
---
6
-
# F# Interactive Options
6
+
# F# Interactive options
7
7
8
-
> [!NOTE]
9
-
> This article currently describes the experience for Windows only. It will be rewritten.
8
+
This article describes the command-line options supported by F# Interactive, `fsi.exe`. F# Interactive accepts many of the same command line options as the F# compiler, but also accepts some additional options.
10
9
11
-
This topic describes the command-line options supported by F# Interactive, `fsi.exe`. F# Interactive accepts many of the same command line options as the F# compiler, but also accepts some additional options.
10
+
## Use F# Interactive for scripting
12
11
13
-
## Using F# Interactive for Scripting
12
+
F# Interactive, `dotnet fsi`, can be launched interactively, or it can be launched from the command line to run a script. The command line syntax is
14
13
15
-
F# Interactive, `fsi.exe`, can be launched interactively, or it can be launched from the command line to run a script. The command line syntax is
16
-
17
-
```console
18
-
> fsi.exe [options] [ script-file [arguments] ]
14
+
```dotnetcli
15
+
dotnet fsi [options] [ script-file [arguments] ]
19
16
```
20
17
21
18
The file extension for F# script files is `.fsx`.
@@ -52,8 +49,6 @@ Where lists appear in F# Interactive option arguments, list elements are separat
52
49
|**--quotations-debug**|Specifies that extra debugging information should be emitted for expressions that are derived from F# quotation literals and reflected definitions. The debug information is added to the custom attributes of an F# expression tree node. See [Code Quotations](code-quotations.md) and [Expr.CustomAttributes](https://msdn.microsoft.com/library/eb89943f-5f5b-474e-b125-030ca412edb3).|
53
50
|**--readline**[**+**|**-**]|Enable or disable tab completion in interactive mode.|
54
51
|**--reference:<filename>**<br /><br />**-r:<filename>**|Same as the **fsc.exe** compiler option. For more information, see [Compiler Options](compiler-options.md).|
55
-
|**--shadowcopyreferences**[**+**|**-**]|Prevents references from being locked by the F# Interactive process.|
56
-
|**--simpleresolution**|Resolves assembly references using directory-based rules rather than MSBuild resolution.|
57
52
|**--tailcalls**[**+**|**-**]|Enable or disable the use of the tail IL instruction, which causes the stack frame to be reused for tail recursive functions. This option is enabled by default.|
58
53
|**--targetprofile:<string>**|Specifies target framework profile of this assembly. Valid values are mscorlib, netcore or netstandard. The default is mscorlib.|
59
54
|**--use:<filename>**|Tells the interpreter to use the given file on startup as initial input.|
@@ -62,7 +57,107 @@ Where lists appear in F# Interactive option arguments, list elements are separat
62
57
|**--warnaserror**[**+**|**-**]|Same as the **fsc.exe** compiler option. For more information, see [Compiler Options](compiler-options.md).|
63
58
|**--warnaserror**[**+**|**-**]:**<int-list>**|Same as the **fsc.exe** compiler option. For more information, see [Compiler Options](compiler-options.md).|
64
59
65
-
## Related Topics
60
+
## F# Interactive structured printing
61
+
62
+
F# Interactive (`dotnet fsi`) uses an extended version of [structured plain text formatting](plaintext-formatting.md) to
63
+
report values.
64
+
65
+
1. All features of `%A` plain text formatting are supported, and some are additionally customizable.
66
+
67
+
2. Printing is colorized if colors are supported by the output console.
68
+
69
+
3. A limit is placed on the length of strings shown, unless you explicitly evaluate that string.
70
+
71
+
4. A set of user-definable settings are available via the `fsi` object.
72
+
73
+
The available settings to customize plain text printing for reported values are:
74
+
75
+
```fsharp
76
+
open System.Globalization
77
+
78
+
fsi.FormatProvider <- CultureInfo("de-DE") // control the default culture for primitives
79
+
80
+
fsi.PrintWidth <- 120 // Control the width used for structured printing
81
+
82
+
fsi.PrintDepth <- 10 // Control the maximum depth of nested printing
83
+
84
+
fsi.PrintLength <- 10 // Control the length of lists and arrays
85
+
86
+
fsi.PrintSize <- 100 // Control the maximum overall object count
87
+
88
+
fsi.ShowProperties <- false // Control whether properties of .NET objects are shown by default
89
+
90
+
fsi.ShowIEnumerable <- false // Control whether sequence values are expanded by default
91
+
92
+
fsi.ShowDeclarationValues <- false // Control whether values are shown for declaration outputs
93
+
```
94
+
95
+
### Customize with `AddPrinter` and `AddPrintTransformer`
96
+
97
+
Printing in F# Interactive outputs can be customized by using `fsi.AddPrinter` and `fsi.AddPrintTransformer`.
98
+
The first function gives text to replace the printing of an object. The second function returns a surrogate object to display
99
+
instead. For example, consider the following F# code:
Copy file name to clipboardExpand all lines: docs/fsharp/language-reference/index.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,7 @@ The following table shows reference topics available that describe language conc
45
45
|[Signatures](signature-files.md)|Describes signatures and signature files. A signature file contains information about the public signatures of a set of F# program elements, such as types, namespaces, and modules. It can be used to specify the accessibility of these program elements.|
46
46
|[XML Documentation](xml-documentation.md)|Describes support for generating documentation files for XML doc comments, also known as triple slash comments. You can produce documentation from code comments in F# just as in other .NET languages.|
47
47
|[Verbose Syntax](verbose-syntax.md)|Describes the syntax for F# constructs when lightweight syntax is not enabled. Verbose syntax is indicated by the `#light "off"` directive at the top of the code file.|
48
+
|[Plain Text Formatting](plaintext-formatting.md)|Learn how to use sprintf and other plain text formatting in F# applications and scripts.|
0 commit comments