argparse でブール型トグルのヘルプ メッセージを折りたたむ上品な方法を探しています。たとえば、次のようになります。
import argparse
parser = argparse.ArgumentParser("booleans")
parser.add_argument('--no-store', action='store_false',
help="Don't do it'")
parser.add_argument('--store', action='store_true',
help="Do it")
parser.print_help()
プリント:
usage: booleans [-h] [--no-store] [--store]
optional arguments:
-h, --help show this help message and exit
--no-store Don't do it'
--store Do it
しかし、私はブール値のフラグをたくさん持っています。私が本当に欲しいのは、それを印刷する方法でそれを書くことができることです:
usage: booleans [-h] [--[no-]store]
optional arguments:
-h, --help show this help message and exit
--[no-]store Do or don't do it.
引数を折りたたんで、カスタム ヘルプ テキストとオプション名を提供する良い方法はありますか?