This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
207 lines (202 loc) · 10.7 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
using System;
using System.Net.NetworkInformation;
using System.Threading;
using SquirrelyCMD;
namespace SquirrelyCMD
{
class Program
{
static string directory = "";
static bool hasDIR = false;
static void Main(string[] args) {
//So there isn't a safe way to change the font size... so that's not goint to happen.
Console.WriteLine("SquirrelyCMD (C)2016 MrSquirrely.net");
for (; true;) {
Console.WriteLine("");
START:
if (hasDIR) {
goto CD_START;
}
Console.Write(">>");
CD_START:
if(hasDIR != false){
Console.Write(directory + ">");
}
string enter = Console.ReadLine();
string[] command = enter.Split(new char[] { ' ' });
switch (command[0].ToLower()) {
case "cd":
if (command.Length > 1) {
if (command[1] == "...") {
hasDIR = false;
goto START;
}
directory = command[1];
hasDIR = true;
goto CD_START;
} else {
Console.WriteLine("Could not complete command");
goto START;
}
case "dir":
SquirrelyUtils.FullDirList(directory);
for (int i = 0; i < SquirrelyUtils.folders.Count; i++) {
Console.WriteLine(SquirrelyUtils.folders[i].ToString());
}
for (int i = 0; i < SquirrelyUtils.files.Count; i++) {
Console.WriteLine(SquirrelyUtils.files[i].ToString());
}
goto CD_START;
case "color":
if (command.Length > 1) {
switch (command[1].ToLower()) {
case "black":
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
Console.Clear();
goto START;
case "blue":
Console.BackgroundColor = ConsoleColor.Blue;
Console.ForegroundColor = ConsoleColor.Black;
Console.Clear();
goto START;
case "cyan":
Console.BackgroundColor = ConsoleColor.Cyan;
Console.ForegroundColor = ConsoleColor.Black;
Console.Clear();
goto START;
default:
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
Console.Clear();
goto START;
}
} else {
Console.WriteLine("Could not complete command");
goto START;
}
case "date":
DateTime localDate = DateTime.Now;
Console.WriteLine(localDate.ToString());
goto START;
case "echo":
if (command.Length > 1) {
string str = "";
for (int i = 1; i < command.Length; i++) {
string str2 = command[i];
str = str +" "+ str2;
}
Console.WriteLine(str);
goto START;
} else {
goto START;
}
case "help":
case "?":
if (command.Length > 1) {
switch (command[1].ToLower()) {
case "help":
Console.WriteLine("Shows a list of all possible commands to choose from");
goto START;
case "ping":
Console.WriteLine("Pings a host to see if it is reachable"
+"\n Possible flags: "
+"\n /A NUMBER - Sets how many times you wish to repet command"
+"\n /i - Sets to repete until closed (Bug:: CTRL + C Closes app, so doesn't work to stop command)");
goto START;
case "cls":
Console.WriteLine("Clears the screen of all text. You can type 'CLS' or 'CLEAR'");
goto START;
case "exit":
Console.WriteLine("Exits the applications... Did you really need to know that?");
goto START;
case "cd":
Console.WriteLine("Changes the current directory, very primitively I will add.");
goto START;
case "dir":
Console.WriteLine("List all files in current Directory, again very primitively I add.");
goto START;
case "color":
Console.WriteLine("Changes the color of the console"
+"\n Possible colors:"
+"\n BLACK"
+"\n BLUE"
+"\n CYAN");
goto START;
case "date":
Console.WriteLine("Shows the date, primitively. I see a trend here.");
goto START;
case "echo":
Console.WriteLine("Echos a string, not much you can do here.");
goto START;
default:
goto START;
}
}
Console.WriteLine("Add command to end to find more info on the command (Ex. help ping)");
Console.WriteLine("Possible Commands");
Console.WriteLine("\n HELP :: Shows all the possible commands"
+"\n PING :: Pings a host to see if it is reachable"
+"\n CLS :: Clears the screen"
+"\n EXIT :: Closes SquirrelyCMD"
+"\n CD :: Changes directory"
+"\n DIR :: List all files and folders in current directory"
+"\n COLOR :: Changes color of console"
+"\n DATE :: Shows current date"
+"\n ECHO :: Echos an inputed string");
goto START;
case "ping":
if (command.Length > 1) {
switch (command[1].ToLower()) {
case "":
Console.WriteLine("Could not complete command");
break;
default:
bool success = true;
Ping pinger = new Ping();
int numberTries = 4;
if (command[2] != null) {
string number = command[2].ToLower();
if (number != "/t") {
try {
numberTries = Int32.Parse(number.Substring(1));
} catch {
}
}else {
numberTries = int.MaxValue;
}
}
try {
PingReply reply = pinger.Send(command[1].ToLower());
Console.WriteLine("Pinging " + command[1].ToLower() + "[" + reply.Address.ToString() + "]");
for (int i = 0; i < numberTries; i++) {
Console.WriteLine(reply.Status.ToString() + " " + reply.RoundtripTime.ToString() + "ms");
Thread.Sleep(1000);
}
} catch (PingException) {
success = false;
}
if (!success) {
Console.WriteLine("Could not complete command");
}
break;
}
}
break;
case "cls":
case "clear":
Console.Clear();
goto START;
case "exit":
Environment.Exit(0);
break;
case "":
goto START;
default:
Console.WriteLine("Unkown command, type in '?' to see a list of possible commands");
goto START;
}
}
}
}
}