Skip to content

Commit

Permalink
Merge pull request #60 from 0x78654C/v1.9.0.2
Browse files Browse the repository at this point in the history
V1.9.0.2
  • Loading branch information
0x78654C authored Sep 22, 2024
2 parents d46cc75 + abe08b3 commit dbe4033
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 70 deletions.
18 changes: 9 additions & 9 deletions Commands/TerminalCommands/ConsoleSystem/BiosInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Core;
using System;
using System.Runtime.Versioning;
using ping = Core.NetWork;
using wmi = Core.Hardware.WMIDetails;
using Ping = Core.NetWork;
using Wmi = Core.Hardware.WMIDetails;

namespace Commands.TerminalCommands.ConsoleSystem
{
Expand Down Expand Up @@ -38,20 +38,20 @@ private static void BiosInformation(string commandType)
case "-r":
Console.Write("Type remote PC name or IP: ");
pc = Console.ReadLine();
if (!ping.PingHost(pc))
if (!Ping.PingHost(pc))
{
Console.WriteLine($"{pc} is offline!");
return;
}
if (GlobalVariables.isPipeCommand)
{
if (GlobalVariables.pipeCmdCount > 0)
GlobalVariables.pipeCmdOutput = wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\" + pc + @"\root\cimv2");
GlobalVariables.pipeCmdOutput = Wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\" + pc + @"\root\cimv2");
else
Console.WriteLine(wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\" + pc + @"\root\cimv2"));
Console.WriteLine(Wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\" + pc + @"\root\cimv2"));
}
else
Console.WriteLine(wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\" + pc + @"\root\cimv2"));
Console.WriteLine(Wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\" + pc + @"\root\cimv2"));
break;
case "-h":
Console.WriteLine(HelpCommand());
Expand All @@ -60,12 +60,12 @@ private static void BiosInformation(string commandType)
if (GlobalVariables.isPipeCommand)
{
if(GlobalVariables.pipeCmdCount > 0)
GlobalVariables.pipeCmdOutput = wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\.\root\cimv2");
GlobalVariables.pipeCmdOutput = Wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\.\root\cimv2");
else
Console.WriteLine(wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\.\root\cimv2"));
Console.WriteLine(Wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\.\root\cimv2"));
}
else
Console.WriteLine(wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\.\root\cimv2"));
Console.WriteLine(Wmi.GetWMIDetails("SELECT * FROM Win32_BIOS", @"\\.\root\cimv2"));
break;
}
}
Expand Down
81 changes: 81 additions & 0 deletions Commands/TerminalCommands/ConsoleSystem/ConsoleEncoding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using Core;
using System;
using System.Runtime.Versioning;
using System.Text;

namespace Commands.TerminalCommands.ConsoleSystem
{
[SupportedOSPlatform("windows")]
public class ConsoleEncoding : ITerminalCommand
{
public string Name => "enc";
private static string s_helpMessage = $@" Usage of enc command:
enc defalut : Set input/output encoding to default .NET encoding.
enc utf8 : Set input/output encoding to UTF8.
enc unicode : Set input/output encoding to Unicode.
enc ascii : Set input/output encoding to ASCII.
enc -current : Show the current input/output encoding.
Default input/output encoding for xTerminal is UTF-8.
";
public void Execute(string arg)
{
if (arg == Name)
{
FileSystem.SuccessWriteLine("Use -h for more information!");
return;
}

arg = arg.Substring(3).Trim().ToLower();

// Display help message.
if (arg.Trim() == "-h")
{
Console.WriteLine(s_helpMessage);
return;
}

if(arg == "-current")
{
var encodingIn = Console.InputEncoding.EncodingName;
var encodingOut = Console.OutputEncoding.EncodingName;
var dataDisplay = $"Input encoding: {encodingIn}\nOutput encoding: {encodingOut}";
FileSystem.SuccessWriteLine(dataDisplay);
return;
}

if (arg == "utf8")
{
Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;
FileSystem.SuccessWriteLine($"Console encoding set to: {Console.InputEncoding.EncodingName}");
return;
}

if (arg == "unicode")
{
Console.InputEncoding = Encoding.Unicode;
Console.OutputEncoding = Encoding.Unicode;
FileSystem.SuccessWriteLine($"Console encoding set to: {Console.InputEncoding.EncodingName}");
return;
}

if (arg == "default")
{
Console.InputEncoding = Encoding.Default;
Console.OutputEncoding = Encoding.Default;
FileSystem.SuccessWriteLine($"Console encoding set to: {Console.InputEncoding.EncodingName}");
return;
}

if (arg == "ascii")
{
Console.InputEncoding = Encoding.ASCII;
Console.OutputEncoding = Encoding.ASCII;
FileSystem.SuccessWriteLine($"Console encoding set to: {Console.InputEncoding.EncodingName}");
return;
}
FileSystem.ErrorWriteLine("The encode type is not part of the lis. Use -h for more information!");
}
}
}
1 change: 1 addition & 0 deletions Commands/TerminalCommands/ConsoleSystem/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void Execute(string arg)
time -- Display current time.
sc -- Manage local or remote computer services. Use -h for additional help.
fw -- Manage local firewall rules. Use -h for additional help.
enc -- Set input/output encoding for xTerminal. Use -h for additional help.
---------------------- File System ---------------------
cat -- Displays the content of a file. Use -h for additional parameters.
Expand Down
10 changes: 2 additions & 8 deletions Commands/TerminalCommands/ConsoleSystem/NewTWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,17 @@ class NewTWindow : ITerminalCommand
";
public void Execute(string args)
{

if (args ==Name && !args.Contains("-u"))
{
FileSystem.SuccessWriteLine($"Use -h param for {Name} command usage!");
return;
}
if (args == $"{Name} -h")
{
Console.WriteLine(s_helpMessage);
return;
}
if (args.ContainsText("-u"))
{
Core.SystemTools.ProcessStart.ProcessExecute(Application.StartupPath + "\\xTerminal.exe", true);
Core.SystemTools.ProcessStart.ProcessExecute(Application.StartupPath + "xTerminal.exe", true);
return;
}
Core.SystemTools.ProcessStart.ProcessExecute(Application.StartupPath + "\\xTerminal.exe", false);
Core.SystemTools.ProcessStart.ProcessExecute(Application.StartupPath + "xTerminal.exe", false);
}
}
}
11 changes: 11 additions & 0 deletions Commands/TerminalCommands/ConsoleSystem/StartProccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;

namespace Commands.TerminalCommands.ConsoleSystem
Expand Down Expand Up @@ -67,6 +68,8 @@ public void Execute(string args)
StartApplication(args, paramApp, true, !waitForExit);
return;
}

args = FileSystem.SanitizePath(args, s_currentDirectory);
StartApplication(args, paramApp, false, !waitForExit);
return;
}
Expand All @@ -78,6 +81,7 @@ public void Execute(string args)
StartApplication(args, paramApp, true, !waitForExit);
return;
}

StartApplication(args, paramApp, false, !waitForExit);
}
catch (Exception e)
Expand All @@ -98,11 +102,18 @@ private void StartApplication(string inputCommand, string arg, bool admin, bool
{
int _ch = Regex.Matches(inputCommand, " ").Count;

if (File.Exists(inputCommand + ".exe"))
inputCommand = inputCommand + ".exe";

if (File.Exists(inputCommand + ".msi"))
inputCommand = inputCommand + ".msi";

if (!File.Exists(inputCommand))
{
FileSystem.ErrorWriteLine($"File {inputCommand} does not exist!");
return;
}

if (admin)
{
Core.SystemTools.ProcessStart.ProcessExecute(inputCommand, arg, true, true, waitForExit);
Expand Down
5 changes: 3 additions & 2 deletions Core/FileSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.VisualBasic;
using Core.SystemTools;
using Microsoft.VisualBasic;
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
Expand Down Expand Up @@ -233,7 +234,7 @@ public static void OpenCurrentDiretory(string dirPath, string currentDirectory)
dirPath = SanitizePath(dirPath, currentDirectory);
if (Directory.Exists(dirPath))
{
SystemTools.ProcessStart.ProcessExecute("explorer", dirPath, false, false, false);
ProcessStart.OpenDirProc(dirPath);
return;
}
Console.WriteLine($"Directory '{dirPath}' does not exist!");
Expand Down
4 changes: 2 additions & 2 deletions Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.2.0")]
[assembly: AssemblyFileVersion("1.7.2.0")]
[assembly: AssemblyVersion("1.7.3.0")]
[assembly: AssemblyFileVersion("1.7.3.0")]
Loading

0 comments on commit dbe4033

Please sign in to comment.