import click


@click.command()
@click.argument('environment')
@click.pass_obj
def ssh(lancet, environment):
    """
    SSH into the given environment, based on the dploi configuration.
    """
    namespace = {}

    with open('deployment.py') as fh:
        code = compile(fh.read(), 'deployment.py', 'exec')
        exec(code, {}, namespace)

    config = namespace['settings'][environment]
    host = '{}@{}'.format(config['user'], config['hosts'][0])
    lancet.defer_to_shell('ssh', '-p', str(config.get('port', 20)), host)

from shlex import quote

import click


@click.command()
@click.option('-p', '--print/--exec', 'print_cmd', default=False,
              help='Print the command instead of executing it.')
@click.argument('environment')
@click.pass_obj
def ssh(lancet, print_cmd, environment):
    """
    SSH into the given environment, based on the dploi configuration.
    """
    namespace = {}

    with open('deployment.py') as fh:
        code = compile(fh.read(), 'deployment.py', 'exec')
        exec(code, {}, namespace)

    config = namespace['settings'][environment]
    host = '{}@{}'.format(config['user'], config['hosts'][0])
    cmd = ['ssh', '-p', str(config.get('port', 20)), host]

    if print_cmd:
        click.echo(' '.join(quote(s) for s in cmd))
    else:
        lancet.defer_to_shell(*cmd)

Allow to print the ssh command
Allow to print the ssh command

+ from shlex import quote
+ 
  import click
  
  
  @click.command()
+ @click.option('-p', '--print/--exec', 'print_cmd', default=False,
+               help='Print the command instead of executing it.')
  @click.argument('environment')
  @click.pass_obj
- def ssh(lancet, environment):
+ def ssh(lancet, print_cmd, environment):
      """
      SSH into the given environment, based on the dploi configuration.
      """
      namespace = {}
  
      with open('deployment.py') as fh:
          code = compile(fh.read(), 'deployment.py', 'exec')
          exec(code, {}, namespace)
  
      config = namespace['settings'][environment]
      host = '{}@{}'.format(config['user'], config['hosts'][0])
-     lancet.defer_to_shell('ssh', '-p', str(config.get('port', 20)), host)
+     cmd = ['ssh', '-p', str(config.get('port', 20)), host]
  
+     if print_cmd:
+         click.echo(' '.join(quote(s) for s in cmd))
+     else:
+         lancet.defer_to_shell(*cmd)
+ 
Allow to print the ssh command
## Code Before:
import click


@click.command()
@click.argument('environment')
@click.pass_obj
def ssh(lancet, environment):
    """
    SSH into the given environment, based on the dploi configuration.
    """
    namespace = {}

    with open('deployment.py') as fh:
        code = compile(fh.read(), 'deployment.py', 'exec')
        exec(code, {}, namespace)

    config = namespace['settings'][environment]
    host = '{}@{}'.format(config['user'], config['hosts'][0])
    lancet.defer_to_shell('ssh', '-p', str(config.get('port', 20)), host)

## Instruction:
Allow to print the ssh command
## Code After:
from shlex import quote

import click


@click.command()
@click.option('-p', '--print/--exec', 'print_cmd', default=False,
              help='Print the command instead of executing it.')
@click.argument('environment')
@click.pass_obj
def ssh(lancet, print_cmd, environment):
    """
    SSH into the given environment, based on the dploi configuration.
    """
    namespace = {}

    with open('deployment.py') as fh:
        code = compile(fh.read(), 'deployment.py', 'exec')
        exec(code, {}, namespace)

    config = namespace['settings'][environment]
    host = '{}@{}'.format(config['user'], config['hosts'][0])
    cmd = ['ssh', '-p', str(config.get('port', 20)), host]

    if print_cmd:
        click.echo(' '.join(quote(s) for s in cmd))
    else:
        lancet.defer_to_shell(*cmd)
