Help text after failure should go to standard error
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Reproducir el comando mostrado en el issue y comparar stdout y stderr cuando se omite la opción obligatoria --ok, también con 2>/dev/null. Se considera terminado cuando la ayuda activada por la validación sigue al error en stderr, mientras que la ayuda solicitada explícitamente con -h permanece en stdout.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When emitting help text because a command's options weren't specified correctly, the help text should be printed to the standard error stream. This avoids mixing diagnostic messages with program output.
The error message is correctly written to stderr, but the help text is not and I think it should match the error message's behavior.
If help was explicitly asked for with -h, then it's probably okay to send that to standard output.
$ dotnet --version
10.0.301
$ cat ok.cs
#!/usr/bin/env dotnet
#:package [email protected]
using System.CommandLine;
var okOption = new Option<bool>("--ok")
{
Description = "Required flag. When passed, the app prints \"ok\".",
Required = true,
};
var rootCommand = new RootCommand("Prints \"ok\" when --ok is passed.")
{
okOption,
};
rootCommand.Validators.Add(result =>
{
if (result.GetResult(okOption) is null)
{
result.AddError($"Option '{okOption.Name}' is required.");
}
});
rootCommand.SetAction(parseResult =>
{
Console.WriteLine("ok");
return 0;
});
return rootCommand.Parse(args).Invoke();
$ dotnet run ok.cs
Option '--ok' is required.
Description:
Prints "ok" when --ok is passed.
Usage:
ok [options]
Options:
--ok (REQUIRED) Required flag. When passed, the app prints "ok".
-?, -h, --help Show help and usage information
--version Show version information
But redirecting stderr to /dev/null shows that the help text (but not the error message) is printed to stdout:
$ dotnet run ok.cs 2> /dev/null
Description:
Prints "ok" when --ok is passed.
Usage:
ok [options]
Options:
--ok (REQUIRED) Required flag. When passed, the app prints "ok".
-?, -h, --help Show help and usage information
--version Show version information
- Lenguaje dominante
- C#
- Estrellas
- 3.7k
- Forks
- 432
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/command-line-api
-
German localization is incompletePosiblemente ocupada @b-v-d-e-v la tomó hace 5 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/command-line-api#2852 ·
-
Incomplete French (fr) translation: RequiredOptionWasNotProvided not translatedPosiblemente ocupada @JPBlanc la tomó hace 103 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/command-line-api#2822 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
dotnet/command-line-api#2792 · 2 comentarios · 15 reacciones ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
dotnet/command-line-api#2704 ·
-
GetCompletions should check exit code of invoked applicationPosiblemente ocupada @baradgur la tomó hace 1274 días. AbiertoArea-Completions bug help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dotnet/command-line-api#2137 · 1 comentario · 3 reacciones ·
Todos los issues de dotnet/command-line-api
Issues similares
-
sev:L
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Systemorph/MeshWeaver#6233 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
CommunityToolkit/Aspire#2231 ·
Los mantenedores suelen responder en 1 día
-
S: Untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Trauma-Station/Trauma-Station#4930 ·
Los mantenedores suelen responder en 1 día
-
agentic-workflows Needs: Triage :mag:
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Cyborg Reverse Hand SwappingAbiertoS: Untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
new-frontiers-14/frontier-station-14#4900 ·
Los mantenedores suelen responder en 2 días