Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC]: Document Environment Variables #363

Closed
adam-grant-hendry opened this issue Aug 23, 2023 · 1 comment
Closed

[DOC]: Document Environment Variables #363

adam-grant-hendry opened this issue Aug 23, 2023 · 1 comment

Comments

@adam-grant-hendry
Copy link

adam-grant-hendry commented Aug 23, 2023

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()
@adam-grant-hendry adam-grant-hendry changed the title [DOC]: Add Setting ANSICON Environment Variable [DOC]: Document Environment Variables Aug 24, 2023
@Secrus
Copy link
Member

Secrus commented Aug 26, 2023

I have added this to the list in #251 I'm going to close this to avoid duplication.

@Secrus Secrus closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants