feat: implement ustcwlt CLI for USTC WLT login

Setup USTC WLT Python Package

Successfully set up the ustcwlt package with CLI to log in to USTC WLT.

Completed Tasks:

  • Explore repository structure and understand current state
  • Bootstrap project (install dependencies, run tests)
  • Rename package from python_template to ustcwlt
  • Implement core login functionality
  • Update __main__.py to call CLI function
  • Add comprehensive tests for the new functionality
  • Verify linting, formatting, and type checking
  • Manual testing of CLI functionality
  • Code review and security scan (CodeQL)
  • Address code review feedback
  • Refactor based on PR comments
    • Use argparse required parameter instead of manual validation
    • Replace print statements with logging module
    • Move success logging to try-except-else clause

Implementation Summary:

Package renamed: python_templateustcwlt 📦 Dependencies added: requests for HTTP requests 🖥️ CLI features:

  • --username (or USTCWLT_USERNAME env var) - required when env var not set
  • --password (or USTCWLT_PASSWORD env var) - required when env var not set
  • --type (default 0, or USTCWLT_TYPE env var)
  • --exp (default 0, or USTCWLT_EXP env var)

Quality Metrics:

Test coverage: 98% (45 statements, 1 uncovered) All tests passing: 8/8 tests Linting: All checks passed (ruff) Type checking: All checks passed (mypy) Security: 0 vulnerabilities found (CodeQL)

Original prompt

This section details on the original issue you should resolve

<issue_title>Set up the project</issue_title> <issue_description>Set up a Python package named ustcwlt, which provides a command-line interface to log in to USTC WLT.

Traditional way to log in to USTC WLT

#!/bin/sh
curl -d "cmd=set&name=${USERNAME}&password=${PASSWORD}&type=${TYPE}&exp=${EXP}" \
  http://wlt.ustc.edu.cn/cgi-bin/ip

Here, ${TYPE} is set to 0 ~ 7, meaning the type of the network exit (http://wlt.ustc.edu.cn/link.html). The recommended value is 0. ${EXP} is the expired time. When it is set to 0, it means no expired time.

Command line interface

The command-line interface should provide the option for username, password, type (by default 0), and exp (by default 0). Also, it should allow setting by the environment variables USTCWLT_* -- if the value has been set by the environment variable, there is no need to set it in the command-line interface.</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes njzjz/ustcwlt#2

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Merge request reports

Loading