Skip to content
This repository was archived by the owner on Feb 19, 2024. It is now read-only.

Commit 186e2ca

Browse files
committed
Add project files.
1 parent 750c2e4 commit 186e2ca

File tree

157 files changed

+8941
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+8941
-0
lines changed

CommandLineOptions.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using CommandLine;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Zephyr
9+
{
10+
[Verb("run", isDefault: true, HelpText = "Run a Zephyr file")]
11+
internal class CommandLineOptions
12+
{
13+
[Option('f', "file", HelpText = "The Zephyr code file to execute")]
14+
public string? FileNameFlag { get; set; } = null;
15+
16+
[Value(0, HelpText = "The Zephyr code file to execute")]
17+
public string? FileName { get; set; } = null;
18+
19+
[Option('p', "pipe", HelpText = "The file path to pipe the output to")]
20+
public string? Pipe { get; set; } = null;
21+
22+
[Option('c', "config", HelpText = "The config file for the application, this can contain all permissions etc")]
23+
public string? Config { get; set; } = null;
24+
25+
[Option("max-runtime", HelpText = "The amount of seconds the program is allowed to execute for")]
26+
public int? MaxRuntime { get; set; } = null;
27+
28+
[Option("max-iterations", HelpText = "The max amount of iterations a loop is allowed to make", Default = 10000)]
29+
public int MaxLoopIterations { get; set; } = 10000;
30+
31+
[Option("no-iteration-limit", HelpText = "Whether or not the loop iteration limit should be disabled", Default = false)]
32+
public bool NoIterationLimit { get; set; } = false;
33+
34+
[Option('a', "file-access", HelpText = "The file permissions the program has access to.\nr = read, w = write, d = delete file, x = delete directory, c = create, n = none\nExample: --file-access=rwdc, -a=n", Default = "rwdxc")]
35+
public string FileAccessFlags { get; set; } = "rwdxc";
36+
37+
[Option("system-details", HelpText = "Whether or not the program has access to system details, e.g. username, operating system etc.", Default = true)]
38+
public bool CanAccessSystemDetails { get; set; } = true;
39+
40+
[Option("debug", HelpText = "Whether or not the interpreter should produce debug information", Default = false)]
41+
public bool Debug { get; set; } = false;
42+
43+
[Option("verbose", HelpText = "Whether or not the interpreter should produce verbose log information", Default = false)]
44+
public bool Verbose { get; set; } = false;
45+
46+
[Option("os-apis", HelpText = "Whether or not the program can access OS api's such as user32.dll", Default = true)]
47+
public bool CanUseSystemAPIs { get; set; } = true;
48+
49+
[Option("can-spawn-processes", HelpText = "Whether or not the program can spawn processes\nDANGEROUS: This will mean it can execute ANY operation on the system", Default = true)]
50+
public bool CanSpawnProcesses { get; set; } = true;
51+
52+
// This is just here for visual
53+
[Option("args", HelpText = "Everything after will count as the args for the Zephyr application")]
54+
public string? Args { get; set; } = null;
55+
}
56+
57+
[Verb("install-package", HelpText = "Install a Zephyr package from a repository")]
58+
internal class CommandLineOptionsInstallPackage
59+
{
60+
[Value(0, HelpText = "The package to install", Required = true)]
61+
public string PackageName { get; set; } = "";
62+
63+
[Value(0, HelpText = "The version of the package", Default = "@latest")]
64+
public string PackageVersion { get; set; } = "@latest";
65+
66+
[Option('r', "repository", HelpText = "The repository URL from which to download the packages", Default = "http://localhost:3000")]
67+
public string RepositoryUrl { get; set; } = "";
68+
}
69+
70+
[Verb("new", HelpText = "Initiate a new Zephyr project / package")]
71+
internal class CommandLineOptionsCreatePackage
72+
{
73+
74+
}
75+
}

Debug.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Pastel;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Zephyr
9+
{
10+
internal class Debug
11+
{
12+
public static void Log(string message, string type = "")
13+
{
14+
if (Program.Options.Debug || Program.Options.Verbose)
15+
Console.WriteLine($"[Debug:{type}] {message}".Pastel(ConsoleColor.Gray));
16+
}
17+
18+
public static void Error(string message, string type = "")
19+
{
20+
if (Program.Options.Debug || Program.Options.Verbose)
21+
Console.WriteLine($"[Debug:{type}] {message}".Pastel(ConsoleColor.Red).PastelBg(ConsoleColor.Gray));
22+
}
23+
24+
public static void Warning(string message, string type = "")
25+
{
26+
if (Program.Options.Debug || Program.Options.Verbose)
27+
Console.WriteLine($"[Warning:{type}] {message}".Pastel(ConsoleColor.Yellow).PastelBg(ConsoleColor.Gray));
28+
}
29+
}
30+
31+
internal class Verbose
32+
{
33+
public static void Log(string message, string type = "")
34+
{
35+
if (Program.Options.Verbose)
36+
Console.WriteLine($"[Verbose:{type}] {message}".Pastel(ConsoleColor.DarkCyan));
37+
}
38+
39+
public static void Error(string message, string type = "")
40+
{
41+
42+
if (Program.Options.Verbose)
43+
Console.WriteLine($"[Verbose:{type}] {message}".Pastel(ConsoleColor.DarkRed).PastelBg(ConsoleColor.DarkCyan));
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)