| 364 | } |
| 365 | |
| 366 | int ModelManager::ShowModelInfo(const std::string &model_name, bool verbose) { |
| 367 | if (model_name.empty()) { |
| 368 | mnncli::UserInterface::ShowError("Model name is required", |
| 369 | "Usage: mnncli model info <name>"); |
| 370 | return 1; |
| 371 | } |
| 372 | |
| 373 | LOG_INFO("Showing model info: " + model_name); |
| 374 | |
| 375 | try { |
| 376 | auto &config_mgr = ConfigManager::GetInstance(); |
| 377 | auto config = config_mgr.LoadConfig(); |
| 378 | mnn::downloader::Config downloader_config; |
| 379 | downloader_config.cache_dir = config.cache_dir; |
| 380 | downloader_config.download_provider = config.download_provider; |
| 381 | std::string model_path = mnn::downloader::FileUtils::GetModelPath(model_name, downloader_config); |
| 382 | |
| 383 | if (model_path.empty()) { |
| 384 | mnncli::UserInterface::ShowError("Model not found: " + model_name); |
| 385 | std::cout << "\n💡 Try:\n"; |
| 386 | std::cout << " • Use 'mnncli list' to see available models\n"; |
| 387 | std::cout << " • Use 'mnncli search <keyword>' to find models\n"; |
| 388 | std::cout << " • Use 'mnncli download <name>' to download models\n"; |
| 389 | return 1; |
| 390 | } |
| 391 | |
| 392 | // Display model information |
| 393 | std::cout << "📁 Model Information: " << model_name << "\n"; |
| 394 | std::cout << "====================\n"; |
| 395 | std::cout << "📍 Download Location: " << model_path << "\n"; |
| 396 | |
| 397 | // Check if it's a symlink |
| 398 | std::error_code ec; |
| 399 | if (fs::is_symlink(model_path, ec)) { |
| 400 | auto target = fs::read_symlink(model_path, ec); |
| 401 | if (!ec) { |
| 402 | std::cout << "🔗 Symlink Target: " << target.string() << "\n"; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | // Get directory size |
| 407 | try { |
| 408 | int64_t total_size = 0; |
| 409 | for (const auto &entry : fs::recursive_directory_iterator(model_path)) { |
| 410 | if (entry.is_regular_file()) { |
| 411 | total_size += entry.file_size(); |
| 412 | } |
| 413 | } |
| 414 | std::cout << "💾 Total Size: " |
| 415 | << mnn::downloader::LogUtils::FormatFileSize(total_size) << "\n"; |
| 416 | } catch (const std::exception &e) { |
| 417 | LOG_DEBUG_TAG("Failed to calculate directory size: " + |
| 418 | std::string(e.what()), |
| 419 | "ModelManager"); |
| 420 | } |
| 421 | |
| 422 | // Look for config.json file |
| 423 | std::string config_path = model_path + "/config.json"; |
nothing calls this directly
no test coverage detected