refactor(clan_lib): move update to clan_lib.clan
This commit is contained in:
@@ -9,10 +9,10 @@ from types import ModuleType
|
||||
from clan_lib.api import directory, disk, mdns_discovery, modules
|
||||
|
||||
from .arg_actions import AppendOptionAction
|
||||
from .clan import show, update
|
||||
from .clan import show
|
||||
|
||||
# API endpoints that are not used in the cli.
|
||||
__all__ = ["directory", "disk", "mdns_discovery", "modules", "update"]
|
||||
__all__ = ["directory", "disk", "mdns_discovery", "modules"]
|
||||
|
||||
from clan_lib.custom_logger import setup_logging
|
||||
from clan_lib.dirs import get_clan_flake_toplevel_or_env
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
from clan_lib.api import API
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix_models.clan import InventoryMeta as Meta
|
||||
from clan_lib.persist.inventory_store import InventorySnapshot, InventoryStore
|
||||
from clan_lib.persist.util import set_value_by_path
|
||||
|
||||
|
||||
@dataclass
|
||||
class UpdateOptions:
|
||||
flake: Flake
|
||||
meta: Meta
|
||||
|
||||
|
||||
@API.register
|
||||
def update_clan_meta(options: UpdateOptions) -> InventorySnapshot:
|
||||
inventory_store = InventoryStore(options.flake)
|
||||
inventory = inventory_store.read()
|
||||
set_value_by_path(inventory, "meta", options.meta)
|
||||
inventory_store.write(inventory, message="Update clan metadata")
|
||||
|
||||
return inventory
|
||||
Reference in New Issue
Block a user