8000 Show help for eval if no code on arg or stdin · dotnet-script/dotnet-script@ee28276 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee28276

Browse files
committed
Show help for eval if no code on arg or stdin
1 parent a1ae8c8 commit ee28276

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Dotnet.Script/Program.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,20 @@ private static int Wain(string[] args)
8383
c.HelpOption(helpOptionTemplate);
8484
c.OnExecute(async () =>
8585
{
86-
var source = string.IsNullOrWhiteSpace(code.Value) ? await Console.In.ReadToEndAsync() : code.Value;
86+
var source = code.Value;
87+
if (string.IsNullOrWhiteSpace(source))
88+
{
89+
if (Console.IsInputRedirected)
90+
{
91+
source = await Console.In.ReadToEndAsync();
92+
}
93+
else
94+
{
95+
c.ShowHelp();
96+
return 0;
97+
}
98+
}
99+
87100
var logFactory = CreateLogFactory(verbosity.Value(), debugMode.HasValue());
88101
var options = new ExecuteCodeCommandOptions(source, cwd.Value(), app.RemainingArguments.Concat(argsAfterDoubleHyphen).ToArray(),configuration.ValueEquals("release", StringComparison.OrdinalIgnoreCase) ? OptimizationLevel.Release : OptimizationLevel.Debug, nocache.HasValue(),packageSources.Values?.ToArray());
89102
return await new ExecuteCodeCommand(ScriptConsole.Default, logFactory).Execute<int>(options);

0 commit comments

Comments
 (0)
0