function main_v50
A command-line interface (CLI) entry point that parses command-line arguments and dispatches to various development tool functions for managing browser cache, static files, and debug endpoints.
/tf/active/vicechatdev/vice_ai/dev_tools.py
84 - 102
simple
Purpose
This function serves as the main entry point for a development tools menu system. It processes command-line arguments to execute different development tasks: clearing browser cache ('clear'), checking static files and debug endpoints ('check'), touching/updating static files ('touch'), or displaying debug endpoint information ('info'). If no valid command is provided, it displays help information.
Source Code
def main():
"""Main development tools menu"""
if len(sys.argv) > 1:
command = sys.argv[1].lower()
if command == "clear":
clear_browser_cache_instructions()
elif command == "check":
check_static_files()
check_debug_endpoint()
elif command == "touch":
touch_static_files()
elif command == "info":
check_debug_endpoint()
else:
print(f"❌ Unknown command: {command}")
print_help()
else:
print_help()
Return Value
This function does not return any value (implicitly returns None). It performs side effects by calling other functions based on command-line arguments and printing output to the console.
Dependencies
requests
Required Imports
import sys
import os
import time
import requests
from pathlib import Path
Usage Example
# Run from command line:
# python script.py clear
# python script.py check
# python script.py touch
# python script.py info
# python script.py # Shows help
# Or call directly in code:
if __name__ == '__main__':
main()
Best Practices
- This function should be called as the entry point of a script using if __name__ == '__main__': main()
- Ensure all helper functions (clear_browser_cache_instructions, check_static_files, check_debug_endpoint, touch_static_files, print_help) are defined before calling main()
- Command-line arguments are case-insensitive due to .lower() conversion
- The function expects sys.argv[1] to contain the command, so it should be run with at least one argument or will display help
- Error handling for unknown commands is built-in and will display help information
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function main_v41 61.1% similar
-
function print_help 60.5% similar
-
function main_v4 60.5% similar
-
function main_v19 59.9% similar
-
function main_v32 58.0% similar