code: def _command(self, args: argparse.Namespace):
      super()._command(args)
      run = self.api.runs.get(args.run_name)
      if run is None:
          raise CLIError(f"Run {args.run_name} not found")
      if not args.diagnose and args.attach:
          if run.status.is_finished():
              raise CLIError(f"Run {args.run_name} is finished")
          else:
              run.attach(args.ssh_identity_file)
      logs = run.logs(diagnose=args.diagnose)
      try:
          for log in logs:
              sys.stdout.buffer.write(log)
              sys.stdout.buffer.flush()
      except KeyboardInterrupt:
          pass
  
file_path: dstack/src/dstack/_internal/cli/commands/logs.py
imports: import argparse
  import sys
  from pathlib import Path
  from dstack._internal.cli.commands import APIBaseCommand
  from dstack._internal.core.errors import CLIError
  from dstack._internal.core.services.ssh.ports import PortUsedError
label_desc: Use image node_id 2 for calling the LogsCommand obj's underlying member method code with example usage: obj._command(args) without return types