Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Return values from actions on Options?

オープン
#2,768 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
csharp
領域
cli

調査の方向性

まず、Option アクションがどのように呼び出され、その戻り値がトップレベルの Invoke 呼び出しを通じてどのように流れるかを追跡します。その動作を Command アクションおよび文書化されている --help の処理と比較し、Option アクションに意図されている契約と、どのような動作またはドキュメントがあれば issue の完了とみなせるかを判断します。

索引モデルが issue の本文から書いたものです。

説明

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?
主要言語
C#
スター
3.7k
フォーク
434
平均マージ
6時間 27分
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/command-line-api のほかの issue

dotnet/command-line-api の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。