Return string with fully composed psql command.

    Accepts optional keyword arguments: user, host, port and maintenance_db,
    as well as any number of positional arguments to be added to the end of
    the command.

def _psql_cmd(*args, **kwargs):
    '''
    Return string with fully composed psql command.

    Accepts optional keyword arguments: user, host, port and maintenance_db,
    as well as any number of positional arguments to be added to the end of
    the command.
    '''
    (user, host, port, maintenance_db) = _connection_defaults(
        kwargs.get('user'),
        kwargs.get('host'),
        kwargs.get('port'),
        kwargs.get('maintenance_db'))
    _PSQL_BIN = _find_pg_binary('psql')
    cmd = [_PSQL_BIN,
           '--no-align',
           '--no-readline',
           '--no-psqlrc',
           '--no-password']  # Never prompt, handled in _run_psql.
    if user:
        cmd += ['--username', user]
    if host:
        cmd += ['--host', host]
    if port:
        cmd += ['--port', six.text_type(port)]
    if not maintenance_db:
        maintenance_db = 'postgres'
    cmd.extend(['--dbname', maintenance_db])
    cmd.extend(args)
    return cmd