Remove unused clan history update subcommand

This commit is contained in:
Jörg Thalheim
2025-04-16 13:49:47 +02:00
parent 3323d2aee8
commit f4792109ec
2 changed files with 0 additions and 53 deletions

View File

@@ -3,7 +3,6 @@ import argparse
from .add import register_add_parser from .add import register_add_parser
from .list import register_list_parser from .list import register_list_parser
from .update import register_update_parser
# takes a (sub)parser and configures it # takes a (sub)parser and configures it
@@ -18,5 +17,3 @@ def register_parser(parser: argparse.ArgumentParser) -> None:
register_add_parser(add_parser) register_add_parser(add_parser)
list_parser = subparser.add_parser("list", help="List recently used flakes") list_parser = subparser.add_parser("list", help="List recently used flakes")
register_list_parser(list_parser) register_list_parser(list_parser)
update_parser = subparser.add_parser("update", help="Update a clan flake")
register_update_parser(update_parser)

View File

@@ -1,50 +0,0 @@
# !/usr/bin/env python3
import argparse
import datetime
from clan_cli.clan.inspect import inspect_flake
from clan_cli.clan_uri import ClanURI
from clan_cli.errors import ClanCmdError
from clan_cli.locked_open import write_history_file
from clan_cli.nix import nix_metadata
from .add import HistoryEntry, list_history
def update_history() -> list[HistoryEntry]:
logs = list_history()
for entry in logs:
try:
meta = nix_metadata(str(entry.flake.flake_url))
except ClanCmdError as e:
print(f"Failed to update {entry.flake.flake_url}: {e}")
continue
new_hash = meta["locked"]["narHash"]
if new_hash != entry.flake.nar_hash:
print(
f"Updating {entry.flake.flake_url} from {entry.flake.nar_hash} to {new_hash}"
)
uri = ClanURI.from_str(
url=str(entry.flake.flake_url),
machine_name=entry.flake.flake_attr,
)
flake = inspect_flake(uri.get_url(), uri.machine_name)
flake.flake_url = flake.flake_url
entry = HistoryEntry(
flake=flake,
last_used=datetime.datetime.now(tz=datetime.UTC).isoformat(),
)
write_history_file(logs)
return logs
def add_update_command(args: argparse.Namespace) -> None:
update_history()
# takes a (sub)parser and configures it
def register_update_parser(parser: argparse.ArgumentParser) -> None:
parser.set_defaults(func=add_update_command)