def build_ssh_command(config, wal_name, peek=0):
    """
    Prepare an ssh command according to the arguments passed on command line

    :param argparse.Namespace config: the configuration from command line
    :param str wal_name: the wal_name get-wal parameter
    :param int peek: in
    :return list[str]: the ssh command as list of string
    """
    ssh_command = ['ssh', '%s@%s' % (config.user, config.barman_host), 'barman'
        ]
    if config.config:
        ssh_command.append('--config %s' % config.config)
    options = []
    if config.test:
        options.append('--test')
    if peek:
        options.append("--peek '%s'" % peek)
    if config.compression:
        options.append('--%s' % config.compression)
    if config.partial:
        options.append('--partial')
    if options:
        get_wal_command = "get-wal %s '%s' '%s'" % (' '.join(options),
            config.server_name, wal_name)
    else:
        get_wal_command = "get-wal '%s' '%s'" % (config.server_name, wal_name)
    ssh_command.append(get_wal_command)
    return ssh_command
