Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Freeshell 2.4.0 Revision 2 #29

Merged
merged 9 commits into from
Jun 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -3,4 +3,6 @@
*.zip
/bin
/obj
/createrelease.sh
/createrelease.sh
obj/Debug/net6.0/
obj/Debug/net6.0/

This file was deleted.

Binary file removed obj/Debug/net6.0/apphost
Binary file not shown.
22 changes: 0 additions & 22 deletions obj/Debug/net6.0/freeshell.AssemblyInfo.cs

This file was deleted.

1 change: 0 additions & 1 deletion obj/Debug/net6.0/freeshell.AssemblyInfoInputs.cache

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions obj/Debug/net6.0/freeshell.GlobalUsings.g.cs

This file was deleted.

Binary file removed obj/Debug/net6.0/freeshell.assets.cache
Binary file not shown.
Binary file not shown.
Empty file.
1 change: 0 additions & 1 deletion obj/Debug/net6.0/freeshell.csproj.CoreCompileInputs.cache

This file was deleted.

69 changes: 0 additions & 69 deletions obj/Debug/net6.0/freeshell.csproj.FileListAbsolute.txt

This file was deleted.

Binary file removed obj/Debug/net6.0/freeshell.dll
Binary file not shown.
1 change: 0 additions & 1 deletion obj/Debug/net6.0/freeshell.genruntimeconfig.cache

This file was deleted.

Binary file removed obj/Debug/net6.0/freeshell.pdb
Binary file not shown.
Binary file removed obj/Debug/net6.0/ref/freeshell.dll
Binary file not shown.
70 changes: 0 additions & 70 deletions obj/freeshell.csproj.nuget.dgspec.json

This file was deleted.

15 changes: 0 additions & 15 deletions obj/freeshell.csproj.nuget.g.props

This file was deleted.

2 changes: 0 additions & 2 deletions obj/freeshell.csproj.nuget.g.targets

This file was deleted.

4,589 changes: 0 additions & 4,589 deletions obj/project.assets.json

This file was deleted.

84 changes: 0 additions & 84 deletions obj/project.nuget.cache

This file was deleted.

27 changes: 23 additions & 4 deletions src/Program.cs
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
using Figgle;
using System;
using Octokit;
using freeshell.cmd;
namespace freeshell
{
public class Program
@@ -11,6 +12,10 @@ public class Program

public static void Main()
{
string currentFilePath = "~/";
string username = Environment.UserName;
string computerName = Environment.MachineName;

var client = new GitHubClient(new ProductHeaderValue("freeshell"));
var releases = client.Repository.Release.GetLatest("dvnlx", "freeshell");
var latest = releases.Result;
@@ -21,7 +26,7 @@ public static void Main()
bool commands = true;
while (commands)
{
Console.Write("( ~/ )");
Console.Write($"( {username}@{computerName} / {currentFilePath} )");
Console.Write("> ");
Console.Write("> ");
Console.Write("§ ");
@@ -32,7 +37,7 @@ public static void Main()
switch (input)
{
case "help":
Console.WriteLine("FRESHELL.NET help \n about: shows the project link \n exit: exits the program \n figlet: make a text to ascii text. \n clcon: clears the console \n color: changes the color. type in \"color\" for more help. \n reload: reloads freeshell. \n fs: the control command for freeshell. type in \"fs\" for help. \n the project is built with c# and .NET\n Thanks");
Console.WriteLine("FRESHELL.NET help \n about: shows the project link \n exit: exits the program \n figlet: make a text to ascii text. \n clcon: clears the console \n color: changes the color. type in \"color\" for more help. \n reload: reloads freeshell. \n fs: the control command for freeshell. type in \"fs\" for help. \n usrinf: showes user information \nthe project is built with c# and .NET\n Thanks");
break;
case "exit":
Console.ForegroundColor = Color.White;
@@ -87,19 +92,33 @@ public static void Main()
case "fs update":
fs.updateLatest();
break;
case var str when str.StartsWith("fs search -r"):
case var str when str.StartsWith("fs search -r"):
input = input.Replace("fs search -r ", "");
fs.searchReleases(input);
break;
case "usrinf":
System.Console.WriteLine("Currently Logged In:");
System.Console.WriteLine($"{username}@{computerName}");
break;
case "dskinf":
dskinf.run();
break;
case "ls":
cmd.listFiles.run();
break;
default:
Console.WriteLine($"{input} Not Found. Type help for help. (FS01)");
break;
}
}else{
}
else
{
System.Console.WriteLine("No command entered (FS05)");
}
}
}


}

public class ProgramInfo
2 changes: 1 addition & 1 deletion src/api/commands/color.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Color = System.ConsoleColor;

namespace freeshell
namespace freeshell.cmd
{
public class color
{
59 changes: 59 additions & 0 deletions src/api/commands/disk/dskinfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.Diagnostics;

namespace freeshell.cmd
{
public class dskinf
{
public static void run()
{
string drivePath = "/"; // Replace with the path of the directory you want to check

long freeSpace;
string fileSystem;

if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
DriveInfo driveInfo = new DriveInfo("C"); // Replace "C" with the drive letter you want to check
freeSpace = driveInfo.AvailableFreeSpace;
fileSystem = driveInfo.DriveFormat;
}
else if (Environment.OSVersion.Platform == PlatformID.Unix)
{
Process process = new Process();
process.StartInfo.FileName = "df";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;

process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();

string[] lines = output.Trim().Split('\n');
string[] fields = lines[1].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
long availableKilobytes = long.Parse(fields[0]);
freeSpace = availableKilobytes * 1024;
fileSystem = fields[1];
}
else
{
Console.WriteLine("Operating system not supported.");
return;
}

Console.WriteLine($"Free Space on your partition: {FormatBytes(freeSpace)}");
Console.WriteLine($"Partition File System: {fileSystem}");
}

static string FormatBytes(long bytes)
{
const int scale = 1024;
string[] units = { "B", "KB", "MB", "GB", "TB", "PB" };

int magnitude = (int)Math.Log(bytes, scale);
decimal adjustedSize = (decimal)bytes / (1L << (magnitude * 10));

return $"{adjustedSize:n2} {units[magnitude]}";
}
}
}
65 changes: 65 additions & 0 deletions src/api/commands/disk/ls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.IO;

namespace freeshell.cmd
{
class listFiles
{
public static void run()
{
string homeFolderPath;

if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
homeFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
}
else if (Environment.OSVersion.Platform == PlatformID.Unix)
{
homeFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
}
else
{
Console.WriteLine("Operating system not supported.");
return;
}

try
{
string[] files = Directory.GetFiles(homeFolderPath);
string[] directories = Directory.GetDirectories(homeFolderPath);

foreach (string file in files)
{
string relativePath = GetRelativePath(file, homeFolderPath);
Console.Write("[FILE]: ");
Console.WriteLine(relativePath);
}

foreach (string directory in directories)
{
string relativePath = GetRelativePath(directory, homeFolderPath);
Console.Write("[DIR]: ");
Console.WriteLine(relativePath);
}
}
catch (Exception ex)
{
Console.WriteLine($"(FS07): An error occurred: {ex.Message}");
}
}

static string GetRelativePath(string fullPath, string basePath)
{
string relativePath;
try
{
relativePath = Path.GetRelativePath(basePath, fullPath);
}
catch (ArgumentException)
{
relativePath = fullPath;
}
return relativePath;
}
}
}
2 changes: 1 addition & 1 deletion src/api/commands/figlet.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

using Figgle;

namespace freeshell
namespace freeshell.cmd
{
public class figlet
{
37 changes: 1 addition & 36 deletions src/api/plugins.cs
Original file line number Diff line number Diff line change
@@ -9,42 +9,7 @@ public class plugins
{
public static void checkForUpdates()
{
// ! THIS IS JUST FOR SHOW !
System.Console.WriteLine("Checking for updates... [fpm]");
Thread.Sleep(1000);
System.Console.WriteLine("Updates found! [fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [# ] 10%[fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [## ] 20%[fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [### ] 30%[fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [#### ] 40%[fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [##### ] 50%[fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [###### ] 60%[fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [####### ] 70%[fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [######## ] 80%[fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [######### ] 90%[fpm]");
Thread.Sleep(1000);
Console.Clear();
System.Console.WriteLine("Downloading updates... [##########] 100%[fpm]");
Thread.Sleep(1000);
System.Console.WriteLine("Updates downloaded! [fpm]");
System.Console.WriteLine("(FS08): Planned for Freeshell 3.0");
}

public static void abtColor(){