拆分代码2

This commit is contained in:
2026-02-04 18:38:34 +08:00
parent eb26a500bb
commit ae64c15efc
2 changed files with 536 additions and 473 deletions

193
shell/CommandList.cs Normal file
View File

@@ -0,0 +1,193 @@
namespace CMLeonOS
{
public static class CommandList
{
public static void ProcessCommand(Shell shell, string command, string args)
{
switch (command)
{
case "echo":
shell.ProcessEcho(args);
break;
case "clear":
case "cls":
shell.ProcessClear();
break;
case "restart":
shell.ProcessRestart();
break;
case "shutdown":
shell.ProcessShutdown();
break;
case "help":
shell.ProcessHelp(args);
break;
case "time":
shell.ProcessTime();
break;
case "date":
shell.ProcessDate();
break;
case "prompt":
shell.ChangePrompt(args);
break;
case "calc":
shell.Calculate(args);
break;
case "history":
shell.ShowHistory();
break;
case "background":
shell.ChangeBackground(args);
break;
case "cuitest":
shell.TestCUI();
break;
case "edit":
shell.EditFile(args);
break;
case "nano":
shell.NanoFile(args);
break;
case "diff":
shell.DiffFiles(args);
break;
case "cal":
shell.ShowCalendar(args);
break;
case "sleep":
shell.SleepCommand(args);
break;
case "com":
shell.ExecuteCommandFile(args);
break;
case "ls":
shell.ProcessLs(args);
break;
case "cd":
shell.ProcessCd(args);
break;
case "pwd":
shell.ProcessPwd();
break;
case "mkdir":
shell.ProcessMkdir(args);
break;
case "rm":
shell.ProcessRm(args);
break;
case "rmdir":
shell.ProcessRmdir(args);
break;
case "cat":
shell.ProcessCat(args);
break;
case "version":
shell.ProcessVersion();
break;
case "about":
shell.ProcessAbout();
break;
case "head":
shell.HeadFile(args);
break;
case "tail":
shell.TailFile(args);
break;
case "wc":
shell.WordCount(args);
break;
case "cp":
shell.CopyFile(args);
break;
case "mv":
shell.MoveFile(args);
break;
case "rename":
shell.RenameFile(args);
break;
case "touch":
shell.CreateEmptyFile(args);
break;
case "find":
shell.FindFile(args);
break;
case "tree":
shell.ShowTree(args);
break;
case "getdisk":
shell.GetDiskInfo();
break;
case "user":
shell.ProcessUserCommand(args);
break;
case "hostname":
shell.ProcessHostnameCommand(args);
break;
case "setdns":
shell.SetDnsServer(args);
break;
case "setgateway":
shell.SetGateway(args);
break;
case "ipconfig":
shell.ShowNetworkConfig();
break;
case "nslookup":
shell.NsLookup(args);
break;
case "cpass":
shell.ProcessCpass();
break;
case "beep":
shell.ProcessBeep();
break;
case "env":
shell.ProcessEnvCommand(args);
break;
case "branswe":
shell.ProcessBransweCommand(args);
break;
case "uptime":
shell.ShowUptime();
break;
case "grep":
shell.GrepFile(args);
break;
case "backup":
shell.BackupSystem(args);
break;
case "restore":
shell.RestoreSystem(args);
break;
case "ftp":
shell.CreateFTP();
break;
case "ping":
shell.PingIP(args);
break;
case "tcpserver":
shell.StartTcpServer(args);
break;
case "tcpclient":
shell.ConnectTcpClient(args);
break;
case "wget":
shell.DownloadFile(args);
break;
case "whoami":
shell.ShowCurrentUsername();
break;
case "base64":
shell.ProcessBase64Command(args);
break;
case "lua":
shell.ExecuteLuaScript(args);
break;
default:
shell.ShowError($"Unknown command: {command}");
break;
}
}
}
}

View File

@@ -110,25 +110,34 @@ namespace CMLeonOS
private void ProcessCommand(string command, string args) private void ProcessCommand(string command, string args)
{ {
switch (command) CommandList.ProcessCommand(this, command, args);
}
public void ProcessEcho(string args)
{
var processedArgs = args.Replace("\\n", "\n");
Console.WriteLine(processedArgs);
}
public void ProcessClear()
{ {
case "echo":
ProcessEcho(args);
break;
case "clear":
case "cls":
Console.Clear(); Console.Clear();
break; }
case "restart":
public void ProcessRestart()
{
Console.WriteLine("Restarting system..."); Console.WriteLine("Restarting system...");
Sys.Power.Reboot(); Sys.Power.Reboot();
break; }
case "shutdown":
public void ProcessShutdown()
{
Console.WriteLine("Shutting down system..."); Console.WriteLine("Shutting down system...");
Sys.Power.Shutdown(); Sys.Power.Shutdown();
break; }
case "help":
// 分页显示帮助信息 public void ProcessHelp(string args)
{
string[] helpArgs = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] helpArgs = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
int pageNumber = 1; int pageNumber = 1;
bool showAll = false; bool showAll = false;
@@ -272,61 +281,35 @@ namespace CMLeonOS
Console.WriteLine("-- End of help --"); Console.WriteLine("-- End of help --");
} }
} }
}
// Console.WriteLine("Startup Script: sys\\startup.cm"); public void ProcessTime()
// Console.WriteLine(" Commands in this file will be executed on startup"); {
// Console.WriteLine(" Each line should contain one command");
// Console.WriteLine(" Lines starting with # are treated as comments");
break;
case "time":
Console.WriteLine(DateTime.Now.ToString()); Console.WriteLine(DateTime.Now.ToString());
break; }
case "date":
public void ProcessDate()
{
Console.WriteLine(DateTime.Now.ToShortDateString()); Console.WriteLine(DateTime.Now.ToShortDateString());
break; }
case "prompt":
ChangePrompt(args); public void ProcessLs(string args)
break; {
case "calc":
Calculate(args);
break;
case "history":
ShowHistory();
break;
case "background":
ChangeBackground(args);
break;
case "cuitest":
TestCUI();
break;
case "edit":
EditFile(args);
break;
case "nano":
NanoFile(args);
break;
case "diff":
DiffFiles(args);
break;
case "cal":
ShowCalendar(args);
break;
case "sleep":
SleepCommand(args);
break;
case "com":
ExecuteCommandFile(args);
break;
case "ls":
fileSystem.ListFiles(args); fileSystem.ListFiles(args);
break; }
case "cd":
public void ProcessCd(string args)
{
fileSystem.ChangeDirectory(args); fileSystem.ChangeDirectory(args);
break; }
case "pwd":
public void ProcessPwd()
{
Console.WriteLine(fileSystem.CurrentDirectory); Console.WriteLine(fileSystem.CurrentDirectory);
break; }
case "mkdir":
public void ProcessMkdir(string args)
{
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
ShowError("Please specify a directory name"); ShowError("Please specify a directory name");
@@ -335,20 +318,20 @@ namespace CMLeonOS
{ {
fileSystem.MakeDirectory(args); fileSystem.MakeDirectory(args);
} }
break; }
case "rm":
public void ProcessRm(string args)
{
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
ShowError("Please specify a file name"); ShowError("Please specify a file name");
} }
else else
{ {
// 检查是否在sys文件夹中修复模式下绕过检测
bool isInSysFolder = (args.Contains(@"\system\") || args.Contains(@"/sys/")) && !fixMode; bool isInSysFolder = (args.Contains(@"\system\") || args.Contains(@"/sys/")) && !fixMode;
if (isInSysFolder) if (isInSysFolder)
{ {
// 检查是否有-norisk参数
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool hasNorisk = false; bool hasNorisk = false;
string filePath = args; string filePath = args;
@@ -374,15 +357,16 @@ namespace CMLeonOS
fileSystem.DeleteFile(args); fileSystem.DeleteFile(args);
} }
} }
break; }
case "rmdir":
public void ProcessRmdir(string args)
{
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
ShowError("Please specify a directory name"); ShowError("Please specify a directory name");
} }
else else
{ {
// 检查是否在sys文件夹中修复模式下绕过检测
bool isInSysFolder = (args.Contains(@"\system\") || args.Contains(@"/sys/")) && !fixMode; bool isInSysFolder = (args.Contains(@"\system\") || args.Contains(@"/sys/")) && !fixMode;
if (isInSysFolder) if (isInSysFolder)
@@ -395,8 +379,10 @@ namespace CMLeonOS
fileSystem.DeleteDirectory(args); fileSystem.DeleteDirectory(args);
} }
} }
break; }
case "cat":
public void ProcessCat(string args)
{
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
ShowError("Please specify a file name"); ShowError("Please specify a file name");
@@ -405,128 +391,34 @@ namespace CMLeonOS
{ {
Console.WriteLine(fileSystem.ReadFile(args)); Console.WriteLine(fileSystem.ReadFile(args));
} }
break; }
case "version":
public void ProcessVersion()
{
Console.WriteLine(Version.DisplayVersion); Console.WriteLine(Version.DisplayVersion);
Console.WriteLine($"Major: {Version.Major}"); Console.WriteLine($"Major: {Version.Major}");
Console.WriteLine($"Minor: {Version.Minor}"); Console.WriteLine($"Minor: {Version.Minor}");
Console.WriteLine($"Patch: {Version.Patch}"); Console.WriteLine($"Patch: {Version.Patch}");
Console.WriteLine($"Full Version: {Version.FullVersion}"); Console.WriteLine($"Full Version: {Version.FullVersion}");
break; }
case "about":
public void ProcessAbout()
{
Console.WriteLine("CMLeonOS Project"); Console.WriteLine("CMLeonOS Project");
Console.WriteLine("By LeonOS 2 Developement Team"); Console.WriteLine("By LeonOS 2 Developement Team");
break;
case "head":
HeadFile(args);
break;
case "tail":
TailFile(args);
break;
case "wc":
WordCount(args);
break;
case "cp":
CopyFile(args);
break;
case "mv":
MoveFile(args);
break;
case "rename":
RenameFile(args);
break;
case "touch":
CreateEmptyFile(args);
break;
case "find":
FindFile(args);
break;
case "tree":
ShowTree(args);
break;
case "getdisk":
GetDiskInfo();
break;
case "user":
ProcessUserCommand(args);
break;
case "hostname":
ProcessHostnameCommand(args);
break;
case "setdns":
SetDnsServer(args);
break;
case "setgateway":
SetGateway(args);
break;
case "ipconfig":
ShowNetworkConfig();
break;
case "nslookup":
NsLookup(args);
break;
case "cpass":
userSystem.ChangePassword();
break;
case "beep":
Console.Beep();
break;
case "env":
ProcessEnvCommand(args);
break;
case "branswe":
ProcessBransweCommand(args);
break;
case "uptime":
ShowUptime();
break;
case "grep":
GrepFile(args);
break;
case "backup":
BackupSystem(args);
break;
case "restore":
RestoreSystem(args);
break;
case "ftp":
CreateFTP();
break;
case "ping":
PingIP(args);
break;
case "tcpserver":
StartTcpServer(args);
break;
case "tcpclient":
ConnectTcpClient(args);
break;
case "wget":
DownloadFile(args);
break;
case "whoami":
ShowCurrentUsername();
break;
case "base64":
ProcessBase64Command(args);
break;
case "lua":
ExecuteLuaScript(args);
break;
default:
ShowError($"Unknown command: {command}");
break;
}
} }
private void ProcessEcho(string args) public void ProcessCpass()
{ {
// 支持基本的转义字符 userSystem.ChangePassword();
var processedArgs = args.Replace("\\n", "\n");
Console.WriteLine(processedArgs);
} }
private void ChangePrompt(string args) public void ProcessBeep()
{
Console.Beep();
}
public void ChangePrompt(string args)
{ {
if (!string.IsNullOrEmpty(args)) if (!string.IsNullOrEmpty(args))
{ {
@@ -538,7 +430,7 @@ namespace CMLeonOS
} }
} }
private void Calculate(string expression) public void Calculate(string expression)
{ {
try try
{ {
@@ -591,7 +483,7 @@ namespace CMLeonOS
} }
} }
private void ShowHistory() public void ShowHistory()
{ {
for (int i = 0; i < commandHistory.Count; i++) for (int i = 0; i < commandHistory.Count; i++)
{ {
@@ -599,7 +491,7 @@ namespace CMLeonOS
} }
} }
private void ChangeBackground(string hexColor) public void ChangeBackground(string hexColor)
{ {
try try
{ {
@@ -717,25 +609,20 @@ namespace CMLeonOS
} }
} }
private void TestCUI() public void TestCUI()
{ {
// 创建CUI实例
var cui = new CUI("CMLeonOS CUI Test"); var cui = new CUI("CMLeonOS CUI Test");
// 设置状态
cui.SetStatus("Testing CUI..."); cui.SetStatus("Testing CUI...");
// 渲染CUI界面只渲染顶栏
cui.Render(); cui.Render();
// 显示测试消息
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("CUI Framework Test"); Console.WriteLine("CUI Framework Test");
Console.WriteLine("-------------------"); Console.WriteLine("-------------------");
Console.WriteLine("Testing CUI functionality..."); Console.WriteLine("Testing CUI functionality...");
Console.WriteLine(); Console.WriteLine();
// 测试不同类型的消息
Console.ForegroundColor = ConsoleColor.Green; Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Success: Success message test"); Console.WriteLine("Success: Success message test");
Console.ResetColor(); Console.ResetColor();
@@ -747,26 +634,22 @@ namespace CMLeonOS
Console.WriteLine("Normal message test"); Console.WriteLine("Normal message test");
Console.WriteLine(); Console.WriteLine();
// 测试用户输入
Console.Write("Enter your name: "); Console.Write("Enter your name: ");
var input = Console.ReadLine(); var input = Console.ReadLine();
Console.WriteLine(); Console.WriteLine();
Console.WriteLine($"Hello, {input}!"); Console.WriteLine($"Hello, {input}!");
Console.WriteLine(); Console.WriteLine();
// 渲染底栏
cui.RenderBottomBar(); cui.RenderBottomBar();
// 等待用户按任意键返回
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Press any key to return to shell..."); Console.WriteLine("Press any key to return to shell...");
Console.ReadKey(true); Console.ReadKey(true);
// 重置控制台
Console.Clear(); Console.Clear();
} }
private void EditFile(string fileName) public void EditFile(string fileName)
{ {
if (string.IsNullOrEmpty(fileName)) if (string.IsNullOrEmpty(fileName))
{ {
@@ -785,7 +668,7 @@ namespace CMLeonOS
} }
} }
private void NanoFile(string fileName) public void NanoFile(string fileName)
{ {
if (string.IsNullOrEmpty(fileName)) if (string.IsNullOrEmpty(fileName))
{ {
@@ -804,7 +687,7 @@ namespace CMLeonOS
} }
} }
private void DiffFiles(string args) public void DiffFiles(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -893,7 +776,7 @@ namespace CMLeonOS
} }
} }
private void ShowCalendar(string args) public void ShowCalendar(string args)
{ {
int year = DateTime.Now.Year; int year = DateTime.Now.Year;
int month = DateTime.Now.Month; int month = DateTime.Now.Month;
@@ -955,7 +838,7 @@ namespace CMLeonOS
Console.WriteLine(); Console.WriteLine();
} }
private void SleepCommand(string args) public void SleepCommand(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -975,7 +858,7 @@ namespace CMLeonOS
} }
} }
private void ExecuteCommandFile(string args) public void ExecuteCommandFile(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1001,9 +884,6 @@ namespace CMLeonOS
return; return;
} }
// Console.WriteLine($"Executing command file: {args}");
// Console.WriteLine("--------------------------------");
foreach (string line in lines) foreach (string line in lines)
{ {
if (string.IsNullOrWhiteSpace(line) || line.Trim().StartsWith("#")) if (string.IsNullOrWhiteSpace(line) || line.Trim().StartsWith("#"))
@@ -1013,9 +893,6 @@ namespace CMLeonOS
ExecuteCommand(line); ExecuteCommand(line);
} }
// Console.WriteLine("--------------------------------");
// ShowSuccess("Command file execution completed");
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1023,7 +900,7 @@ namespace CMLeonOS
} }
} }
private void HeadFile(string args) public void HeadFile(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1069,7 +946,7 @@ namespace CMLeonOS
} }
} }
private void TailFile(string args) public void TailFile(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1081,7 +958,7 @@ namespace CMLeonOS
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
string fileName = parts[0]; string fileName = parts[0];
int lineCount = 10; // 默认显示10行 int lineCount = 10;
if (parts.Length > 1) if (parts.Length > 1)
{ {
@@ -1116,7 +993,7 @@ namespace CMLeonOS
} }
} }
private void WordCount(string args) public void WordCount(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1159,7 +1036,7 @@ namespace CMLeonOS
} }
} }
private void CopyFile(string args) public void CopyFile(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1181,7 +1058,6 @@ namespace CMLeonOS
string sourceFile = parts[0]; string sourceFile = parts[0];
string destFile = parts[1]; string destFile = parts[1];
// 使用FileSystem读取源文件内容
string content = fileSystem.ReadFile(sourceFile); string content = fileSystem.ReadFile(sourceFile);
if (content == null) if (content == null)
{ {
@@ -1189,7 +1065,6 @@ namespace CMLeonOS
return; return;
} }
// 使用FileSystem写入目标文件
fileSystem.WriteFile(destFile, content); fileSystem.WriteFile(destFile, content);
ShowSuccess($"File copied successfully from '{sourceFile}' to '{destFile}'"); ShowSuccess($"File copied successfully from '{sourceFile}' to '{destFile}'");
} }
@@ -1199,7 +1074,7 @@ namespace CMLeonOS
} }
} }
private void MoveFile(string args) public void MoveFile(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1243,7 +1118,7 @@ namespace CMLeonOS
} }
} }
private void RenameFile(string args) public void RenameFile(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1292,7 +1167,7 @@ namespace CMLeonOS
} }
} }
private void CreateEmptyFile(string args) public void CreateEmptyFile(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1313,7 +1188,7 @@ namespace CMLeonOS
} }
} }
private void FindFile(string args) public void FindFile(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1324,13 +1199,11 @@ namespace CMLeonOS
try try
{ {
// 使用FileSystem获取当前目录的文件列表
var files = fileSystem.GetFileList("."); var files = fileSystem.GetFileList(".");
bool found = false; bool found = false;
foreach (var file in files) foreach (var file in files)
{ {
// 检查文件名是否包含搜索字符串
if (file.ToLower().Contains(args.ToLower())) if (file.ToLower().Contains(args.ToLower()))
{ {
Console.WriteLine($"Found: {file}"); Console.WriteLine($"Found: {file}");
@@ -1349,7 +1222,7 @@ namespace CMLeonOS
} }
} }
private void ShowTree(string args) public void ShowTree(string args)
{ {
string startPath = string.IsNullOrEmpty(args) ? "." : args; string startPath = string.IsNullOrEmpty(args) ? "." : args;
string fullPath = fileSystem.GetFullPath(startPath); string fullPath = fileSystem.GetFullPath(startPath);
@@ -1423,7 +1296,7 @@ namespace CMLeonOS
} }
} }
private void GetDiskInfo() public void GetDiskInfo()
{ {
Console.WriteLine("===================================="); Console.WriteLine("====================================");
Console.WriteLine(" Disk Information"); Console.WriteLine(" Disk Information");
@@ -1431,7 +1304,6 @@ namespace CMLeonOS
try try
{ {
// 使用VFSManager获取所有磁盘
var disks = Sys.FileSystem.VFS.VFSManager.GetDisks(); var disks = Sys.FileSystem.VFS.VFSManager.GetDisks();
if (disks == null || disks.Count == 0) if (disks == null || disks.Count == 0)
@@ -1463,7 +1335,7 @@ namespace CMLeonOS
return $"{size:F2} {units[unitIndex]}"; return $"{size:F2} {units[unitIndex]}";
} }
private void ProcessHostnameCommand(string args) public void ProcessHostnameCommand(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1474,7 +1346,7 @@ namespace CMLeonOS
userSystem.ProcessHostnameCommand(args); userSystem.ProcessHostnameCommand(args);
} }
private void ProcessUserCommand(string args) public void ProcessUserCommand(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1538,7 +1410,7 @@ namespace CMLeonOS
} }
} }
private void ProcessBransweCommand(string args) public void ProcessBransweCommand(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1568,7 +1440,7 @@ namespace CMLeonOS
} }
} }
private void GrepFile(string args) public void GrepFile(string args)
{ {
if (string.IsNullOrEmpty(args)) if (string.IsNullOrEmpty(args))
{ {
@@ -1624,7 +1496,7 @@ namespace CMLeonOS
} }
} }
private void ProcessEnvCommand(string args) public void ProcessEnvCommand(string args)
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
@@ -1730,7 +1602,7 @@ namespace CMLeonOS
} }
} }
private void BackupSystem(string args) public void BackupSystem(string args)
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
@@ -1802,7 +1674,7 @@ namespace CMLeonOS
} }
} }
private void RestoreSystem(string args) public void RestoreSystem(string args)
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
@@ -1909,7 +1781,7 @@ namespace CMLeonOS
} }
} }
private void ShowUptime() public void ShowUptime()
{ {
try try
{ {
@@ -1918,7 +1790,6 @@ namespace CMLeonOS
Console.WriteLine("===================================="); Console.WriteLine("====================================");
Console.WriteLine(); Console.WriteLine();
// 计算系统运行时间
if (Kernel.SystemStartTime != DateTime.MinValue) if (Kernel.SystemStartTime != DateTime.MinValue)
{ {
TimeSpan uptime = DateTime.Now - Kernel.SystemStartTime; TimeSpan uptime = DateTime.Now - Kernel.SystemStartTime;
@@ -1927,7 +1798,6 @@ namespace CMLeonOS
Console.WriteLine("Current time: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("Current time: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
Console.WriteLine(); Console.WriteLine();
// 格式化运行时间
int days = uptime.Days; int days = uptime.Days;
int hours = uptime.Hours; int hours = uptime.Hours;
int minutes = uptime.Minutes; int minutes = uptime.Minutes;
@@ -1949,7 +1819,7 @@ namespace CMLeonOS
} }
} }
private void CreateFTP() public void CreateFTP()
{ {
Console.WriteLine("===================================="); Console.WriteLine("====================================");
Console.WriteLine(" FTP Server"); Console.WriteLine(" FTP Server");
@@ -2025,7 +1895,7 @@ namespace CMLeonOS
// Console.WriteLine($"Server stopped at: {DateTime.Now:yyyy-MM-dd HH:mm:ss}"); // Console.WriteLine($"Server stopped at: {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
} }
private void PingIP(string args) public void PingIP(string args)
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
@@ -2151,7 +2021,7 @@ namespace CMLeonOS
return true; return true;
} }
private void StartTcpServer(string args) public void StartTcpServer(string args)
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
@@ -2243,7 +2113,7 @@ namespace CMLeonOS
} }
} }
private void ConnectTcpClient(string args) public void ConnectTcpClient(string args)
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
@@ -2323,7 +2193,7 @@ namespace CMLeonOS
} }
} }
private void DownloadFile(string args) public void DownloadFile(string args)
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
@@ -2433,7 +2303,7 @@ namespace CMLeonOS
} }
} }
private void ShowCurrentUsername() public void ShowCurrentUsername()
{ {
Console.WriteLine("===================================="); Console.WriteLine("====================================");
Console.WriteLine(" Current User"); Console.WriteLine(" Current User");
@@ -2443,7 +2313,7 @@ namespace CMLeonOS
Console.WriteLine(); Console.WriteLine();
} }
private void ProcessBase64Command(string args) public void ProcessBase64Command(string args)
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
@@ -2503,7 +2373,7 @@ namespace CMLeonOS
} }
} }
private void ExecuteLuaScript(string args) public void ExecuteLuaScript(string args)
{ {
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
@@ -2680,7 +2550,7 @@ namespace CMLeonOS
} }
} }
private void SetDnsServer(string args) public void SetDnsServer(string args)
{ {
if (string.IsNullOrWhiteSpace(args)) if (string.IsNullOrWhiteSpace(args))
{ {
@@ -2702,7 +2572,7 @@ namespace CMLeonOS
} }
} }
private void SetGateway(string args) public void SetGateway(string args)
{ {
if (string.IsNullOrWhiteSpace(args)) if (string.IsNullOrWhiteSpace(args))
{ {
@@ -2724,7 +2594,7 @@ namespace CMLeonOS
} }
} }
private void ShowNetworkConfig() public void ShowNetworkConfig()
{ {
Console.WriteLine("===================================="); Console.WriteLine("====================================");
Console.WriteLine(" Network Configuration"); Console.WriteLine(" Network Configuration");
@@ -2743,7 +2613,7 @@ namespace CMLeonOS
Console.WriteLine(); Console.WriteLine();
} }
private void NsLookup(string args) public void NsLookup(string args)
{ {
if (string.IsNullOrWhiteSpace(args)) if (string.IsNullOrWhiteSpace(args))
{ {