Invalid verbs do not cause errors if a default verb is set
まだ誰も着手していません。
評価
調査の方向性
Issue に示されている Parser.ParseArguments 呼び出しから始め、デフォルト動詞を有効にした状態で DefaultVerb.exe foo を使用して動作を再現します。デフォルト動詞が存在する場合に認識されない動詞がどのように処理されるかを追跡し、その後、無効な入力が DoSomething やデフォルト動詞ではなくエラーパスに到達することを確認します。
索引モデルが issue の本文から書いたものです。
説明
Below is a very simplified C# console application I called DefaultVerb. Running the application with start or finish works as expected, outputting Start or Finish correctly, but if I run the application with DefaultVerb.exe foo, it outputs Start. If I set isDefault to false, and run DefaultVerb.exe foo I receive the following expected error:
ERROR(S):
Verb 'foo' is not recognized.
--help Display this help screen.
--version Display version information.
When I have isDefault: true on my verb, what should be the behavior if I pass in an invalid verb? I'm not expecting a bad verb to run my default verb.
`
using CommandLine;
using System;
internal class Program
{
[Verb("start", isDefault: true, HelpText = "start help")]
class StartOptions
{
}
[Verb("finish", HelpText = "finish help")]
class FinishOptions
{
}
static void Main(string[] args)
{
var parser = new Parser(settings =>
{
settings.AutoVersion = false;
settings.CaseSensitive = false;
settings.HelpWriter = Console.Out;
});
parser.ParseArguments<StartOptions, FinishOptions>(args)
.WithNotParsed(ExitWithError)
.WithParsed(DoSomething);
}
static void DoSomething(object commandObj)
{
switch (commandObj)
{
case StartOptions:
Console.WriteLine("Start");
break;
case FinishOptions:
Console.WriteLine("Finish");
break;
}
}
static void ExitWithError(IEnumerable<Error> errors)
{
Environment.Exit(1);
}
}
`
- 主要言語
- C#
- スター
- 4.8k
- フォーク
- 478
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
commandlineparser/commandline のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
commandlineparser/commandline#951 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
commandlineparser/commandline#880 · リアクション 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
commandlineparser/commandline#952 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
commandlineparser/commandline#948 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
commandlineparser/commandline#947 ·
commandlineparser/commandline の issue をすべて見る
似ている issue
-
bug frontend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
NavigationViewItemAutomationPeer implements IInvokeProvider but never advertises the Invoke pattern オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
unoplatform/uno#24629 ·
-
agentic-workflows Needs: Triage :mag: State: In-PR
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
apache/arrow-adbc#4809 ·