Halide-controlled extending–shrinking motion of a covalent cage