Question:
This is my first post so apologies for any mistakes.
I ran the dotnet command in the Windows Powershell and It gave me a description of how to use it:
1 2 3 4 5 6 |
Usage: dotnet [host-options] [command] [arguments] [common-options] Common options: -v|--verbose Enable verbose output -h|--help Show help |
When I ran the command
1 2 |
dotnet run -h|--help |
It gave me the following error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
At line:1 char:17 + dotnet run -h|--help + ~ Missing expression after unary operator '--'. At line:1 char:15 + dotnet run -h|--help + ~~ Expressions are only allowed as the first element of a pipeline. At line:1 char:17 + dotnet run -h|--help + ~~~~ Unexpected token 'help' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingExpressionAfterOperator |
Any ideas why this is happening? Why is the command not showing help as intended? Having searched everywhere, I haven’t been able to get a conclusive answer.
Answer:
-v|--verbose
means you can use either -v
or --verbose
; the |
in this context is BNF‘s ‘or’ symbol.
Many options come in short form with a single (or few) letters mnemonic, or in long form which is more descriptive of the option. The short form will start with a single dash, while the long form starts with two dashes.
|
in the context of powershell
is a pipe, which separates commands, and the errors you see is the interpreter trying to make sense of --help
as a command : it understands --
as the unary minus, but can’t make sense of help
in that context.
You probably want to use dotnet run -h
.