Skip to content

Commit

Permalink
Update click dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed Dec 8, 2024
1 parent 0235106 commit 231a051
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
58 changes: 34 additions & 24 deletions pynitrokey/cli/nethsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,15 @@ def generate_key(
@click.option("--public-key", is_flag=True, help="Query the public key")
@click.option("--certificate", is_flag=True, help="Query the certificate")
@click.pass_context
def get_config(ctx: Context, **kwargs: bool) -> None:
def get_config(
ctx: Context,
logging: bool,
network: bool,
time: bool,
unattended_boot: bool,
public_key: bool,
certificate: bool,
) -> None:
"""Query the configuration of a NetHSM.
Only the configuration items selected with the corresponding option are
Expand All @@ -916,40 +924,42 @@ def get_config(ctx: Context, **kwargs: bool) -> None:
role."""
with connect(ctx) as nethsm:
print(f"Configuration for NetHSM {nethsm.host}:")
show_all = not any(kwargs.values())
show_all = not any(
[logging, network, time, unattended_boot, public_key, certificate]
)

if show_all or kwargs["logging"]:
logging = nethsm.get_config_logging()
if show_all or logging:
logging_config = nethsm.get_config_logging()
print(" Logging:")
print(" IP address: ", logging.ip_address)
print(" Port: ", logging.port)
print(" Log level: ", logging.log_level)
print(" IP address: ", logging_config.ip_address)
print(" Port: ", logging_config.port)
print(" Log level: ", logging_config.log_level)

if show_all or kwargs["network"]:
network = nethsm.get_config_network()
if show_all or network:
network_config = nethsm.get_config_network()
print(" Network:")
print(" IP address: ", network.ip_address)
print(" Netmask: ", network.netmask)
print(" Gateway: ", network.gateway)
print(" IP address: ", network_config.ip_address)
print(" Netmask: ", network_config.netmask)
print(" Gateway: ", network_config.gateway)

if show_all or kwargs["time"]:
time = nethsm.get_config_time()
print(" Time: ", time)
if show_all or time:
time_config = nethsm.get_config_time()
print(" Time: ", time_config)

if show_all or kwargs["unattended_boot"]:
unattended_boot = nethsm.get_config_unattended_boot()
print(" Unattended boot:", unattended_boot)
if show_all or unattended_boot:
unattended_boot_config = nethsm.get_config_unattended_boot()
print(" Unattended boot:", unattended_boot_config)

if show_all or kwargs["public_key"]:
public_key = nethsm.get_public_key()
if show_all or public_key:
public_key_config = nethsm.get_public_key()
print(" Public key:")
for line in public_key.splitlines():
for line in public_key_config.splitlines():
print(f" {line}")

if show_all or kwargs["certificate"]:
certificate = nethsm.get_certificate()
if show_all or certificate:
certificate_config = nethsm.get_certificate()
print(" Certificate:")
for line in certificate.splitlines():
for line in certificate_config.splitlines():
print(f" {line}")


Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers = [
]
dependencies = [
"cffi",
"click >=8.0, <=8.1.3",
"click >=8.1.6, <9",
"cryptography >=41.0.4,<44",
"ecdsa",
"fido2 >=1.1.2,<2",
Expand Down Expand Up @@ -110,7 +110,6 @@ warn_return_any = false
module = [
"cbor.*",
"cffi.*",
"click.*",
"ecdsa.*",
"intelhex.*",
"nacl.*",
Expand Down

0 comments on commit 231a051

Please sign in to comment.