/
Doggich
/
CodeRepresentation
Обзор
Документация
Войти
/
Doggich
/
CodeRepresentation
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/modules/argsParser.py
65 строк
2 KB
Doggich
refactoring: script structure
10 янв 2026, 19:23
10 янв 2026, 19:23
6336d86
Код
Авторство
О чём код?
import argparse def build_arg_parser() -> argparse.ArgumentParser: """ Creates and configures a command line argument parser for the GitHub Repository Exporter. This function sets up the argument parser with three main arguments: - GitHub repository URL (required positional argument) - GitHub personal access token (optional) - Output filename (optional) ### Returns: argparse.ArgumentParser: A configured argument parser ready to parse command line arguments. ### Arguments: url (positional): GitHub repository URL to export. Format: https://github.com/owner/repository Example: https://github.com/Doggich/DemoSceneEffect -t, --token (optional): GitHub personal access token for authentication. Using a token increases API rate limits and allows access to private repositories. Example: --token ghp_abc123def456 -o, --output (optional): Output filename for the exported repository content. If not specified, defaults to a timestamped filename: repository_content_YYYYMMDDHHMMSS.txt Example: --output my_repository.txt """ parser = argparse.ArgumentParser( description="Export complete structure and content of a GitHub repository to a text file", epilog=""" Examples: %(prog)s https://github.com/Doggich/DemoSceneEffect %(prog)s https://github.com/Doggich/DemoSceneEffect --token ghp_your_token_here %(prog)s https://github.com/Doggich/DemoSceneEffect --output my_repo.txt %(prog)s https://github.com/Doggich/DemoSceneEffect -t ghp_your_token_here -o output.txt """ ) # Required positional argument for GitHub URL parser.add_argument( "url", type=str, help="GitHub repository URL (e.g., https://github.com/owner/repository)" ) # Optional argument for GitHub token parser.add_argument( "-t", "--token", type=str, dest="token", default=None, help="GitHub personal access token for increased API limits and private repos" ) # Optional argument for output filename parser.add_argument( "-o", "--output", type=str, dest="output_file", default=None, help="Output filename (default: repository_content_YYYYMMDDHHMMSS.txt)" ) return parser