| 304 | |
| 305 | |
| 306 | class GenShortcutsCommand(Command): |
| 307 | name = "gen-shortcuts" |
| 308 | help = "generate shortcut `mzcompose` shell scripts in mzcompose directories" |
| 309 | |
| 310 | def run(self, args: argparse.Namespace) -> None: |
| 311 | repo = mzbuild.Repository.from_arguments(MZ_ROOT, args) |
| 312 | template = """#!/usr/bin/env bash |
| 313 | |
| 314 | # Copyright Materialize, Inc. and contributors. All rights reserved. |
| 315 | # |
| 316 | # Use of this software is governed by the Business Source License |
| 317 | # included in the LICENSE file at the root of this repository. |
| 318 | # |
| 319 | # As of the Change Date specified in that file, in accordance with |
| 320 | # the Business Source License, use of this software will be governed |
| 321 | # by the Apache License, Version 2.0. |
| 322 | # |
| 323 | # mzcompose — runs Docker Compose with Materialize customizations. |
| 324 | |
| 325 | exec "$(dirname "$0")"/{}/bin/pyactivate -m materialize.cli.mzcompose "$@" |
| 326 | """ |
| 327 | for path in repo.compositions.values(): |
| 328 | mzcompose_path = path / "mzcompose" |
| 329 | with open(mzcompose_path, "w") as f: |
| 330 | f.write(template.format(os.path.relpath(repo.root, path))) |
| 331 | mzbuild.chmod_x(mzcompose_path) |
| 332 | |
| 333 | |
| 334 | class ListCompositionsCommand(Command): |