ssh.py 1.0 KB

123456789101112131415161718192021222324252627282930
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. import argparse
  10. from materialize.cli.scratch import check_required_vars
  11. from materialize.scratch import get_instance, mssh
  12. def configure_parser(parser: argparse.ArgumentParser) -> None:
  13. check_required_vars()
  14. parser.add_argument(
  15. "instance",
  16. help="The ID of the instance to connect to, or 'mine' to specify your only live instance",
  17. )
  18. parser.add_argument("command", nargs="*", help="The command to run via SSH, if any")
  19. def run(args: argparse.Namespace) -> None:
  20. # SSH will join together multiple arguments with spaces, so we don't lose
  21. # anything by doing the same.
  22. instance = get_instance(args.instance)
  23. mssh(instance, " ".join(args.command))