"""
Functions for validating user input to tasks.
"""

from fabric.api import abort, env
import os


def validate_templates_dir(templates_dir):
    """
    Template directory must be defined and exist.
    """
    if not templates_dir or not os.path.isdir(templates_dir):
        abort('Please provide a valid templates_dir')


def validate_data_dir(data_dir):
    """
    Data directory must be defined and exist.
    """
    if not data_dir or not os.path.isdir(data_dir):
        abort('Please provide a valid data_dir')


def validate_generated_dir(generated_dir):
    """
    Generated directory must be defined and not be a regular file.
    """
    if not generated_dir or (os.path.exists(generated_dir) and not os.path.isdir(generated_dir)):
        abort('Please provide a valid generated_dir')


def validate_remotes_dir(remotes_dir):
    """
    Remotes directory must be defined and not be a regular file.
    """
    if not remotes_dir or (os.path.exists(remotes_dir) and not os.path.isdir(remotes_dir)):
        abort('Please provide a valid remotes_dir')


def validate_host():
    """
    Fabric host_string must be defined.
    """
    if not env.host_string:
        abort('Please specify a host or a role')


def validate_all(templates_dir, data_dir, generated_dir, remotes_dir):
    """
    Validate templates_dir, data_dir, generated_dir, remotes_dir, and host.
    """
    validate_templates_dir(templates_dir)
    validate_data_dir(data_dir)
    validate_generated_dir(generated_dir)
    validate_remotes_dir(remotes_dir)
    validate_host()


def validate_generate(templates_dir, data_dir, generated_dir):
    """
    Validate templates_dir, data_dir, generated_dir, and host.
    """
    validate_templates_dir(templates_dir)
    validate_data_dir(data_dir)
    validate_generated_dir(generated_dir)
    validate_host()


def validate_pull(templates_dir, data_dir, remotes_dir):
    """
    Validate templates_dir, data_dir, remotes_dir, and host.
    """
    validate_templates_dir(templates_dir)
    validate_data_dir(data_dir)
    validate_remotes_dir(remotes_dir)
    validate_host()

@@ -231,296 +231,489 @@
 _dir
- or not os.path.isdir(templates_dir):%0A        abort('Please provide a valid templates_dir')%0A%0A%0Adef validate_data_dir(data_dir):%0A    %22%22%22%0A    Data directory must be defined and exist.%0A    %22%22%22%0A    if not data_dir or not os.path.isdir(data_dir):%0A        abort('Please provide a valid data_dir'
+:%0A        abort('Please provide a valid templates directory')%0A    elif not os.path.isdir(templates_dir):%0A        abort('%7Btemplates_dir%7D is not a valid directory'.format(templates_dir=templates_dir))%0A%0A%0Adef validate_data_dir(data_dir):%0A    %22%22%22%0A    Data directory must be defined and exist.%0A    %22%22%22%0A    if not data_dir:%0A        abort('Please provide a valid data_dir')%0A    elif not os.path.isdir(data_dir):%0A        abort('%7Bdata_dir%7D is not a valid directory'.format(data_dir=data_dir)
 )%0A%0A%0A
@@ -858,29 +858,89 @@
 enerated_dir
- or (
+:%0A        abort('Please provide a valid generated_dir')%0A    elif 
 os.path.exis
@@ -989,25 +989,24 @@
 nerated_dir)
-)
 :%0A        ab
@@ -1014,45 +1014,85 @@
 rt('
-Please provide a valid generated_dir'
+%7Bgenerated_dir%7D is not a valid directory'.format(generated_dir=generated_dir)
 )%0A%0A%0A
@@ -1237,13 +1237,71 @@
 _dir
- or (
+:%0A        abort('Please provide a valid remotes_dir')%0A    elif 
 os.p
@@ -1358,17 +1358,16 @@
 tes_dir)
-)
 :%0A      
@@ -1379,43 +1379,79 @@
 rt('
-Please provide a valid remotes_dir'
+%7Bremotes_dir%7D is not a valid directory'.format(remotes_dir=remotes_dir)
 )%0A%0A%0A

Improve argument validation. Provide directory string checked if provided.