Return values from actions on Options?
还没有人认领这个 Issue。
评估
调研方向
首先追踪 Option actions 的调用方式,以及它们的返回值如何通过顶层 Invoke 调用传递。将该行为与 Command actions 以及文档中对 --help 的处理方式进行比较,然后确定 Option actions 的预期 contract,以及什么样的行为或文档可以将该 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:
- what is the point of setting actions on an
Optionobject? (And what is the point of being able to return an integer from those actions?) - what is the intended way to detect that --help was invoked so you can terminate the application?
- 主要语言
- C#
- 星标
- 3.7k
- 派生
- 434
- 平均合并
- 4 小时 46 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/command-line-api 的其他 Issue
-
German localization is incomplete可能已有人在做 @b-v-d-e-v 于 8 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
dotnet/command-line-api#2852 ·
-
Incomplete French (fr) translation: RequiredOptionWasNotProvided not translated可能已有人在做 @JPBlanc 于 105 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
dotnet/command-line-api#2822 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
dotnet/command-line-api#2792 · 2 条评论 · 16 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 62/100
dotnet/command-line-api#2704 ·
-
GetCompletions should check exit code of invoked application可能已有人在做 @baradgur 于 1277 天前认领。 未关闭Area-Completions bug help wanted
难度 2/5 1-3 小时 新手友好度 72/100
dotnet/command-line-api#2137 · 1 条评论 · 3 个 reaction ·
查看 dotnet/command-line-api 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
PCL-Community/PCL-CE#3658 ·
维护者通常 1 天内回复
-
Deploy & Patch-issues opprettes ikke: create-pnd-issues.yml har feilet hver uke siden 2025-09-08未关闭
难度 2/5 1-3 小时 新手友好度 62/100
Altinn/altinn-auth#4359 ·
维护者通常 1 天内回复
-
アプリ: チャット 優先: 中 提案
难度 2/5 1-3 小时 新手友好度 70/100
yksr-melt/Meltype#243 · 1 条评论 ·
维护者通常 1 天内回复
-
bug core
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
type/automation type/tech-debt
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复