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

required Boolean with non-default value

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

メンテナーはふだん 3 日以内に返信

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
java
領域
cli

調査の方向性

Start by reproducing the annotated command examples using Boolean and boolean, then inspect how @Option required, defaultValue, and help-menu optionality are processed. Compare omitted options with explicit true and false values; done means a required Boolean option has no implicit choice and the help output and command validation consistently reflect that.

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

説明

status/need-triage

spring shell version: 3.1.6

In one of my commands, I want to make sure that the end-user specifically indicates whether they either want A or B by using a Boolean. I don't want to make the choice for the end user.

When I add the following @Option on my command:

@Option(required = true, description = "Description", longNames = "Some long name")  Boolean booleanOption

Spring Shell, automatically transforms the booleanOption to defaultValue false. The help menu of the command indicates that the booleanOption is optional.

When transforming into

@Option(required = true, description = "Description", longNames = "Some long name")  boolean booleanOption

Still, the help menu indicates the booleanOption as optional. I assume for 2 reasons that this should not be the case: (1) it is a boolean and not Boolean. (2) required is explicitly set to true. The defaultValue is again false.

Setting the defaultValue to 'true' explicitly seems to be working.

@Option(required = true, description = "Description", longNames = "Some long name", defaultValue = "true")boolean booleanOption

It will show that the boolean is optional, but the default value will be true.

But again, I didn't want to choose for the user. I want the end user to articulate their choice when doing a command specifically.

If I write:

@Option(required = true, description = "Description", longNames = "Some long name", defaultValue = "")Boolean booleanOption

Or

@Option(required = true, description = "Description", longNames = "Some long name", defaultValue = "null")Boolean booleanOption

The defaultValue still translates to false (while as a Boolean I would expect it to be able to be null).

Is this the intended behavior?

主要言語
Java
スター
826
フォーク
405
平均マージ
6日 9時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

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

spring-projects/spring-shell のほかの issue

spring-projects/spring-shell の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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