From 570302360ddc648f4d665c9d04eb34033a8f788b Mon Sep 17 00:00:00 2001 From: mulhern Date: Wed, 18 Dec 2024 12:26:34 -0500 Subject: [PATCH] Specify default values, show them in help text Signed-off-by: mulhern --- src/stratis_cli/_actions/_pool.py | 12 ++---------- src/stratis_cli/_parser/_pool.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/stratis_cli/_actions/_pool.py b/src/stratis_cli/_actions/_pool.py index f94d1b95a..2c6184b0f 100644 --- a/src/stratis_cli/_actions/_pool.py +++ b/src/stratis_cli/_actions/_pool.py @@ -199,16 +199,8 @@ def create_pool(namespace): # pylint: disable=too-many-locals if clevis_info is None else (True, (clevis_info.pin, json.dumps(clevis_info.config))) ), - "journal_size": ( - (False, 0) - if namespace.journal_size is None - else (True, namespace.journal_size.magnitude.numerator) - ), - "tag_spec": ( - (False, 0) - if namespace.tag_spec is None - else (True, namespace.tag_spec) - ), + "journal_size": (True, namespace.journal_size.magnitude.numerator), + "tag_spec": (True, namespace.tag_spec), }, ) diff --git a/src/stratis_cli/_parser/_pool.py b/src/stratis_cli/_parser/_pool.py index e78f41c9d..853a6c865 100644 --- a/src/stratis_cli/_parser/_pool.py +++ b/src/stratis_cli/_parser/_pool.py @@ -20,6 +20,9 @@ from argparse import SUPPRESS, ArgumentTypeError from uuid import UUID +# isort: THIRDPARTY +from justbytes import MiB, Range + from .._actions import BindActions, PoolActions from .._constants import ( Clevis, @@ -185,9 +188,12 @@ def _ensure_nat(arg): "Size of integrity device's journal. " "Each block is written to this journal " "before being written to its address. " - "The size of the journal must be a " - "multiple of 4 KiB." + "The default is %(default)s. Specify " + "0B if you have determined that you " + "will never make use of integrity " + "features." ), + "default": Range(128, MiB), "type": parse_range, }, ), @@ -198,10 +204,13 @@ def _ensure_nat(arg): "Integrity tag specification defining " "the size of the tag used to store a " "checksum or other value for each " - "block on a device. stratisd chooses " - "a default specification if none is " - "given." + "block on a device. All size " + "specifications are in bits. The " + "default is %(default)s. Specify 0b " + "if you have determined that you will " + "never make use of integrity features." ), + "default": IntegrityTagSpec.B512, "choices": list(IntegrityTagSpec), "type": IntegrityTagSpec, },