Skip to content

[DOC]: Document Environment Variables #363

@adam-grant-hendry

Description

@adam-grant-hendry

Can the documentation please be updated to incorporate a running list of environment variables that cleo reads and/or sets? I ran a simple python script (see below) to identify such variables and these would be as listed below:

ANSICON
TERM_PROGRAM
SHELL
COLORTERM
TERM

We will want to add FORCE_COLOR and NO_COLOR to this list as well once PR #343 is merged.

find_used_env_vars.py
import os
import re

def find_used_env_vars(filename):
    used_env_vars = set()

    with open(filename) as file:
        content = file.read()
        matches = re.findall(r'os\.environ\[[\'"]([A-Z_]+)[\'"]\]', content)
        used_env_vars.update(matches)

        matches = re.findall(r'os\.environ\.get\([\'"]([A-Z_]+)[\'"]\)', content)
        used_env_vars.update(matches)

        matches = re.findall(r'os\.getenv\([\'"]([A-Z_]+)[\'"]\)', content)
        used_env_vars.update(matches)

        matches = re.findall(r'os\.getenvb\([\'"]([A-Z_]+)[\'"]\)', content)
        used_env_vars.update(matches)

    return used_env_vars

def main():
    result = set()

    for root, _, files in os.walk('.'):
        for file in files:
            if file.endswith('.py'):
                file_path = os.path.join(root, file)
                result.update(find_used_env_vars(file_path))

    with open('output.txt', 'w') as output_file:
        for var in result:
            output_file.write(var + '\n')

if __name__ == "__main__":
    main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions