text: #!/usr/bin/env python
  import os
  import click
  import six
  import platform
  from pyfiglet import figlet_format
  from termcolor import colored
  from dataspot.scripts.script_grouper import ScriptGrouper
  from dataspot.relationships.import_director import ImportDirector
  from dataspot.relationships.relationships_director import RelationshipsDirector
  from dataspot.relationships.writer.text_file_writer import TextFileWriter
  
  
  @click.command()
  @click.option('--results_path', default=os.path.abspath('../../examples/results'),
                prompt='Where can DataSpot store the results?',
                type=click.Path(exists=True),
                help='Please provide a directory path to which DataSpot has read and write right.')
  def main(results_path):
      dataspot_results = os.path.join(results_path, 'dataspot_results.json')
      dataspot_results_exists = os.path.isfile(dataspot_results)
  
      use_results = False
      if dataspot_results_exists:
          use_results = click.prompt('It seems like you already have DataSpot results present in this directory. '
                                     'Do you wish to use these results?', default=False)
          if not use_results:
              # This will trigger a new build of the configurators analysis.
              os.remove(dataspot_results)
          else:
              config_path = click.prompt('Please enter the path to the configuration file (JSON)',
                                         default=os.path.abspath('../dataspot_config.json'), type=click.Path(exists=True))
  
              # Since we already have the results, we can do the command line call to the Dataspot servers, which launces
              # the configurators analysis/visualizations.
              path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'servers/bokeh_server.py'))
  
              if platform.system().lower() == 'windows':
                  config_path = '"' + config_path + '"'
                  path = '"' + path + '"'
                  dataspot_results = '"' + dataspot_results + '"'
  
              command = "python " + path + " -c " + config_path + " -r " + dataspot_results
  
              os.system(command)
  
      if not use_results:
          # The parser configuration must exist in the main folder of DataSpot. Otherwise, an error will be thrown.
          parser_config_path = os.path.abspath('../parser_config.json')
          parser_config_present = os.path.isfile(parser_config_path)
  
          if not parser_config_present:
              raise FileNotFoundError(
                  "The parser configuration cannot be found. Please make sure the parser configuration "
                  "exists in the main part of the program")
  
          # DataSpot needs a directory path. Stating a file path will result in an error. In case you do not provide
          # a directory, DataSpot will use the example configurators analysis
          scripts_path = click.prompt('Please enter the path to the directory that contains your SQL scripts.',
                                      type=click.Path(exists=True), default=os.path.abspath('../../examples/scripts'))
  
          # 1. The scripts path is already validated by Click. Hence, why we don't need to double check this.
          # 2. All scripts are first grouped based on the #DATASPOT tag. An error will occur when a script is not tagged
          # or is tagged with an unsupported type
          scripts = ScriptGrouper.group(scripts_path=scripts_path)
  
          # DataSpot needs a configuration file (with .json extension) in order to customize your configurators analysis. In
          # case the user does not provide a file path, DataSpot will use the default configuration file.
          config_path = click.prompt('Please enter the path to the configuration file (JSON)',
                                     default=os.path.abspath('../dataspot_config.json'), type=click.Path(exists=True))
  
          # DataSpot offers the possibility to read in relationships for your configurators analysis from Excel and
          # JSON. These files need to be in a specific format. Please see the DataSpot documentation for more
          # information on this.
          resources = click.prompt('Do you want to read in additional files? These can be Excel files, or JSON files.',
                                   default=False)
  
          resources_path = None
          if resources:
              resources_path = click.prompt('Please enter the full path to the directory containing the additional files',
                                            default=os.path.join(os.path.abspath('../../'), 'examples/resources'),
                                            type=click.Path(exists=True))
  
          # The relationships variable is a dictionary containing the object-name as key, and the object-sources
          # represented in a list, as the key's value
          relationships = RelationshipsDirector.build(scripts=scripts, parser_config_path=parser_config_path)
  
          if resources_path:
              import_director = ImportDirector(relationships=relationships)
              relationships = import_director.build(path=resources_path)
  
          # All of the relationships DataSpot could find in the scripts will be put in a .json file. This is convenient
          # for the user but is also necessary for the execution of the visualizations part of DataSpot. This requires the
          # relationships to be present in a separate file.
          text_file_writer = TextFileWriter()
          results_path = text_file_writer.write(path=results_path, data=relationships, title='dataspot_results',
                                                timestamp=False, extension='json')
  
          # A command line call to the DataSpot servers, which launches the configurators analysis/visualizations
          path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "servers", "bokeh_server.py"))
  
          if platform.system().lower() == 'windows':
              config_path = '"' + config_path + '"'
              path = '"' + path + '"'
              results_path = '"' + results_path + '"'
  
          command = "python " + path + " -c " + config_path + " -r " + results_path
          os.system(command)
  
  
  # This function prints the colored start screen in the terminal window
  def figlet(string, color, font="slant", figlet=False):
      if colored:
          if not figlet:
              six.print_(colored(string, color))
          else:
              six.print_(colored(figlet_format(string, font=font), color))
      else:
          six.print_(string)
  
  
  # This function provides the text for the colored start screen in the terminal window.
  def start():
      figlet(string= "DataSpot", color='cyan', figlet=True)
      figlet("DataSpot is a script visualizations tool which takes scripts that are used for data inserts \n"
             "and provide the user with full data lineage. \n\n"
             "Currently, Dataspot supports the following database scripting languages: \n\n"
             "[*] Teradata SQL \n", "white")
      figlet("Welcome to Dataspot", "blue")
  
  
  if __name__ == "__main__":
      start()
      main()
  
  
  # TODO: Save all of the results in dictionary, so that the calculation will only be done once.
  