mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
拆分代码6
This commit is contained in:
36
shell/Commands/Script/BransweCommand.cs
Normal file
36
shell/Commands/Script/BransweCommand.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace CMLeonOS.Commands.Script
|
||||
{
|
||||
public static class BransweCommand
|
||||
{
|
||||
public static void ProcessBransweCommand(string args, CMLeonOS.FileSystem fileSystem, Action<string> showError)
|
||||
{
|
||||
if (string.IsNullOrEmpty(args))
|
||||
{
|
||||
showError("Error: Please specify file name");
|
||||
showError("Usage: branswe <filename>");
|
||||
return;
|
||||
}
|
||||
|
||||
string filePath = fileSystem.GetFullPath(args);
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
showError($"Error: File not found: {args}");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string fileContent = File.ReadAllText(filePath);
|
||||
Branswe.Run(fileContent);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
showError($"Error executing Branswe: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user