Last active
April 1, 2021 16:54
-
-
Save warmwaffles/66a40b7c409e8039149764beaa45e915 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import re | |
DOCUMENTATION = re.compile(r"((?:^# [^\n]+\n)+)^([^#:]+):", re.MULTILINE) | |
STRIP = re.compile(r"(\n)|(#)") | |
YELLOW = '\033[93m' | |
GREEN = '\033[32m' | |
RESET = '\033[0m' | |
BOLD = '\033[01m' | |
print(f"{BOLD}Usage:{RESET}") | |
print(f" make {GREEN}[command]{RESET}") | |
print(f"{BOLD}Commands:{RESET}") | |
commands = {} | |
for makefile in sys.argv[1:]: | |
with open(makefile, "r") as f: | |
content = f.read() | |
for match in DOCUMENTATION.findall(content): | |
commands[match[1]] = re.sub(STRIP, "", match[0]) | |
largest = 0 | |
for task in commands: | |
current = len(task) | |
if current > largest: | |
largest = current | |
for task, message in commands.items(): | |
print(f"{YELLOW}{task.rjust(largest)}{RESET} -{message}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some help text here | |
thing: | |
@echo boooo | |
# Show this help. | |
help: | |
@python make_help.py $(MAKEFILE_LIST) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment