Confusing behavior when order of long/short options are swapped
まだ誰も着手していません。
評価
調査の方向性
option_description::option_description(const char*, const value_semantic*) と、文書化されている名前形式のルールから始めます。"h,help" を使って単純なテストプログラムでの動作を再現し、その後、順序を入れ替えた名前を明示的に受け入れるべきか拒否すべきかを判断します。誤った使用によって分かりにくい実行時の動作が発生しなくなり、意図した動作がテストでカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Adding an option like this:
desc.add_options()( "h,help", "Print help and exit" );
In a simple test program and then trying to use --help results in a confusing error:
$ ./prog --help
libc++abi.dylib: terminating with uncaught exception of type boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::unknown_option> >: unrecognised option '--help'
The documentation for option_description::option_description(const char*, const value_semantic*) says:
The 'name' parameter is interpreted by the following rules:
if there's no "," character in 'name', it specifies long name
otherwise, the part before "," specifies long name and the part after -- short name.
However, it is easy for new users of this library to think that swapping them is OK.
The reason for this limitation isn't clear to me -- presumably, if one is "long" and the other "short", providing them in either order should be OK, and a simple test can tell which is which. In either case, the error message on misuse is needlessly cryptic and could probably be turned into an error thrown from option_description::option_description. This seems reasonable, since using "h,help" as the option name results in bad behavior regardless: the resulting executable has options --h and -h.
- 主要言語
- C++
- スター
- 136
- フォーク
- 117
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
boostorg/program_options のほかの issue
-
Provide C++20 moduleオープン
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
boostorg/program_options#160 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
boostorg/program_options#159 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
boostorg/program_options#147 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
boostorg/program_options#146 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
boostorg/program_options#144 ·
boostorg/program_options の issue をすべて見る
似ている issue
-
HasBacktrace Priority-Critical
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
azerothcore/azerothcore-wotlk#27921 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
yhirose/cpp-peglib#344 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
ExpressLRS/ExpressLRS#3805 ·
メンテナーはふだん 2 日以内に返信