#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""网络信息Skill"""

import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

from skills.base_skill import BaseSkill
from network_tools import run_network_info, run_public_ip


class NetworkInfoSkill(BaseSkill):
    """网络信息Skill"""
    
    def get_metadata(self):
        return {
            "name": "network_info",
            "display_name": "网络信息",
            "description": "查询本机网络信息(IP/MAC/网关/DNS等)",
            "category": "info",
            "keywords": ["网络", "信息", "ip", "mac", "网关", "dns", "配置"],
            "parameters": [
                {
                    "name": "info_type",
                    "type": "string",
                    "required": False,
                    "default": "all",
                    "description": "信息类型:all(全部)/ip/public/gateway"
                }
            ],
            "examples": [
                "查看网络信息",
                "查看本机IP",
                "查看公网IP"
            ],
            "requires_admin": False,
            "requires_ui": False
        }
    
    def execute(self, info_type: str = "all") -> str:
        """查询网络信息"""
        info_type = info_type.lower()
        
        if info_type == "public":
            return run_public_ip()
        else:
            return run_network_info(info_type)
