项目文件夹

文件
2026-07-13 13:33:03 +08:00

69 行
2.0 KiB
C++

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
//
// Created by AI Assistant on 2024/12/25.
// Copyright (c) 2024 Alibaba Group Holding Limited All rights reserved.
//
#ifndef USER_INTERFACE_HPP
#define USER_INTERFACE_HPP
#include <string>
#include <iostream>
#include <iomanip>
namespace mnncli {
// User interface utilities
class UserInterface {
public:
static void ShowWelcome() {
std::cout << "🚀 MNN CLI - MNN Command Line Interface\n";
std::cout << "Type 'mnncli --help' for available commands\n\n";
}
static void ShowProgress(const std::string& message, float progress) {
int bar_width = 50;
int pos = static_cast<int>(bar_width * progress);
// Clear the line first to prevent leftover characters
std::cout << "\r\033[K" << message << " [";
for (int i = 0; i < bar_width; ++i) {
if (i < pos) {
std::cout << "█"; // Filled block
} else if (i == pos) {
std::cout << "▶"; // Arrow
} else {
std::cout << "░"; // Light block
}
}
// Add padding to prevent leftover characters
std::cout << "] " << std::fixed << std::setprecision(1) << (progress * 100.0) << "%"
<< std::string(3, ' ')
<< std::flush;
if (progress >= 1.0) std::cout << std::endl;
}
static void EndProgress() {
std::cout << std::endl;
}
static void ShowError(const std::string& error, const std::string& suggestion = "") {
std::cerr << "❌ Error: " << error << std::endl;
if (!suggestion.empty()) {
std::cerr << "💡 Suggestion: " << suggestion << std::endl;
}
}
static void ShowSuccess(const std::string& message) {
std::cout << "✅ " << message << std::endl;
}
static void ShowInfo(const std::string& message) {
std::cout << "️ " << message << std::endl;
}
};
} // namespace mnncli
#endif // USER_INTERFACE_HPP