Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Return values from actions on Options?

Abierto
#2,768 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
cli

Línea de trabajo

Comienza rastreando cómo se invocan las acciones de Option y cómo sus valores de retorno fluyen a través de la llamada de nivel superior Invoke. Compara ese comportamiento con las acciones de Command y con el manejo documentado de --help; después, determina cuál es el contrato previsto para las acciones de Option y qué comportamiento o documentación definiría el issue como resuelto.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

I'm trying to work out the "right" way to use this library, and a very simple use case that puzzles me is "detect that --help was invoked, so we can terminate the application after handling arguments", and it is not really clear to me how that should be done.

My first thought was that I should attach an Action to the Option, and have that action return non-zero, which would propagate out to the top-level Invoke call. Then I'd check the return value there, and if non-zero, terminate the application.

But if an Option's action returns non-zero the return value just seems to be discarded.

I also noted that none of the documentation seems to use actions on Option objects, and that while actions on Command objects can just be lambdas, the ones on Option have to be a class derived from CommandLineAction. It kind of feels like Option actions are a bit half-baked? Are they not supposed to be used?

So two questions:

  1. what is the point of setting actions on an Option object? (And what is the point of being able to return an integer from those actions?)
  2. what is the intended way to detect that --help was invoked so you can terminate the application?
Lenguaje dominante
C#
Estrellas
3.7k
Forks
434
Merge medio
4 h 46 min
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dotnet/command-line-api

Todos los issues de dotnet/command-line-api

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.