import os
import shutil
import difflib

def get_all_commands():
    paths = os.environ.get("PATH", "").split(os.pathsep)
    cmds = set()

    for p in paths:
        try:
            for f in os.listdir(p):
                # Optionally check if executable
                cmds.add(f)
        except Exception:
            pass

    return list(cmds)

def suggest(cmd):
    commands = get_all_commands()

    # get_close_matches returns a list of the best matches
    matches = difflib.get_close_matches(cmd, commands, n=1, cutoff=0.6)

    if matches:
        return matches[0]

    return None
