Help for cdv.copy

cdv ยท copy

Sample CLI

gway cdv copy

References

Full Code

def copy(table_path: str, old_entry: str, new_entry: str, **kwargs) -> bool:
    """Copy a record from old_entry to new_entry, optionally updating fields."""
    path = _resolve_path(table_path)
    records = _read_table(path)
    if old_entry not in records:
        gw.warn(f"Entry '{old_entry}' does not exist; cannot copy.")
        return False
    # Shallow copy of fields
    new_fields = records[old_entry].copy()
    new_fields.update(kwargs)
    records[new_entry] = new_fields
    _write_table(path, records)
    gw.info(f"Copied '{old_entry}' to '{new_entry}' with updates: {kwargs}")
    return True