# TODO: Docstrings

import processes.base
import platform


class WhereIsProcess(processes.base.BaseProcess):
    # TODO: Docstrings
    def execute(self, program_name):
        # TODO: Docstrings
        if 'windows' in platform.system().lower():
            command_name = 'where'
        else:
            command_name = 'whereis'
        output, _ = super().run_process([command_name, program_name])

        # Windows and Linux have different output for this process. Annoying, but doable.
        if 'windows' in platform.system().lower():
            if output.strip() != 'INFO: Could not find files for the given pattern(s).':
                output = output.split('\n')
        else:
            output = output.replace(program_name + ':', '').strip()

            # Search results are delimited by a space, as opposed to Windows which is a new line
            output = output.split(' ')

        return output
