Created
May 13, 2021 19:55
-
-
Save JacobCallahan/0aa53aeaa354ef5d967706ccf05ec3fa to your computer and use it in GitHub Desktop.
you know the thing...
This file contains 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 time | |
import random | |
# ['test_cli.py', 'sub-command', '--option1', '17', '--test-flag'] | |
# fix --test-case 0971v2s983a123-sad3t13rg-re36570-4563 --auto-merge | |
# close --test-case | |
# yolo --420 | |
def print_help(): | |
print("""Let's do some things with test cases! | |
Sub-commands: | |
fix fix a test case | |
close close a test case | |
yolo DOS Satlab | |
Options: | |
--test-case id of a test case | |
--auto-merge automatically merge if passing | |
--420 fuck it | |
--42 answer | |
-h, --help print help and exit | |
""") | |
sys.exit(0) | |
def process_input(arg_list): | |
arg_list.pop(0) | |
arg_dict = {"sub": arg_list.pop(0)} | |
if "--auto-merge" in arg_list: | |
arg_dict["merge"] = True | |
arg_list.remove("--auto-merge") | |
if "--420" in arg_list: | |
arg_dict[420] = True | |
arg_list.remove("--420") | |
if "--42" in arg_list: | |
arg_dict[42] = True | |
arg_list.remove("--42") | |
if "--test-case" in arg_list: | |
arg_list.remove("--test-case") | |
arg_dict["test-case"] = arg_list | |
return arg_dict | |
def fix(test_cases=None, merge=False): | |
for case in test_cases: | |
print(f"Hey, I'm fixing {case=}..") | |
time.sleep(random.randint(1,5)) | |
if random.choice([0,1]): | |
print("Test was fixed!") | |
if merge: | |
print(f"merging {case=} in upstream") | |
else: | |
print("Test wasn't fixed :{") | |
def close(test_cases=None): | |
for case in test_cases: | |
print(f"I closed {case=}. Yep") | |
def yolo(is_420=False, is_42=False): | |
if is_42: | |
print(f"Put all your money in dodgecoin, brah!!") | |
if is_420: | |
print("....um.. blaze?") | |
time.sleep(random.randint(5,15)) | |
print("what were we doing?") | |
if random.choice([0,1]): | |
yolo(is_420, is_42) | |
def run(processed): | |
if processed["sub"] == "fix": | |
if "test-case" not in processed: | |
print_help() | |
fix(processed["test-case"], processed.get("merge")) | |
if processed["sub"] == "close": | |
if "test-case" not in processed: | |
print_help() | |
close(processed["test-case"]) | |
if processed["sub"] == "yolo": | |
yolo(processed.get(420), processed.get(42)) | |
if __name__ == "__main__": | |
if "-h" in sys.argv or "--help" in sys.argv: | |
print_help() | |
print(sys.argv) | |
processed = process_input(sys.argv) | |
print(processed) | |
run(processed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment