Skip to content

Commit

Permalink
Initial commit <duplicate>
Browse files Browse the repository at this point in the history
  • Loading branch information
sctech-tr committed Oct 26, 2024
1 parent 6a8a3d5 commit 1ba94b3
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 30 deletions.
143 changes: 143 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.svclog
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml
*.azurePubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
packages/
## TODO: If the tool you use requires repositories.config, also uncomment the next line
!packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
![Ss]tyle[Cc]op.targets
~$*
*~
*.dbmdl
*.[Pp]ublish.xml

*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac desktop service store files
.DS_Store

_NCrunch*





# jetbrains rider
.idea/
*.idea
.idea
*.idea/
23 changes: 14 additions & 9 deletions Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public static void GetDateTime()

public static void Magic8Ball()
{
string[] responses = {
string[] responses =
[
"yes!",
"no.",
"maybe?",
Expand All @@ -74,7 +75,8 @@ public static void Magic8Ball()
"sudo rm -rf /*",
"deleting system32...",
"U+200C",
"yesyesyesyesyesyesyesyesNO"};
"yesyesyesyesyesyesyesyesNO"
];
Random random = new Random();
Console.WriteLine(responses[random.Next(responses.Length)]);
}
Expand Down Expand Up @@ -125,20 +127,22 @@ public static void SelfDestruct()

public static void Fortune()
{
string[] fortunes = { "you will find a penny on the ground today.", "beware of coding bugs tomorrow.", "an unexpected error will bring great wisdom.", "today is the day to ignore deadlines.", "you will forget your password when you need it most." };
string[] fortunes = ["you will find a penny on the ground today.", "beware of coding bugs tomorrow.", "an unexpected error will bring great wisdom.", "today is the day to ignore deadlines.", "you will forget your password when you need it most."
];
Random random = new Random();
Console.WriteLine(fortunes[random.Next(fortunes.Length)]);
}

public static void TellAJoke()
{
string[] jokes = {
string[] jokes =
[
// TODO: add more jokes
"why do programmers hate nature? it has too many bugs.",
"how many programmers does it take to change a light bulb? none, that's a hardware problem!",
"why do java developers wear glasses? because they don’t C#.",
"i told my computer i needed a break, and now it won’t stop sending me ads for vacations."
};
];
Random random = new Random();
Console.WriteLine(jokes[random.Next(jokes.Length)]);
}
Expand All @@ -156,13 +160,14 @@ public static void Lag()

public static void UselessFact()
{
string[] facts = {
string[] facts =
[
"bananas are berries, but strawberries aren’t.",
"wombat poop is cube-shaped.",
"there is a species of jellyfish that is immortal.",
"ketchup was sold as medicine in the 1830s.",
"octopuses have three hearts."
};
];
Random random = new Random();
Console.WriteLine(facts[random.Next(facts.Length)]);
}
Expand All @@ -188,7 +193,7 @@ public static void UnknownCommand()
Console.WriteLine("tellajoke - tell a joke");
Console.WriteLine("lag - process some REALLY important info");
Console.WriteLine("facts - a random useless fact");
Console.WriteLine("");
Console.WriteLine("unicode - prints a random unicode character");

}
}
78 changes: 57 additions & 21 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
namespace theuselesscmd;
using System.Net.Mail;
using System.Net.Mime;

namespace theuselesscmd;

class Program
{
static void Main()
{
Console.WriteLine("welcome to theuselesscmd!");

while (true)
// Password validation if password is set
if (Commands.IsPasswordProtected)
{
// Password validation if password is set
if (Commands.IsPasswordProtected)
{
Console.Write("enter password to continue: ");
string? inputPassword = Console.ReadLine();
Console.Write("enter password to continue: ");
string? inputPassword = Console.ReadLine();

if (inputPassword != null && !Commands.ValidatePassword(inputPassword))
{
Console.WriteLine("incorrect password! access denied.");
continue;
}

Console.WriteLine("access granted.");
}
else
if (inputPassword != null && !Commands.ValidatePassword(inputPassword))
{
Console.WriteLine("no password set. Use 'pass set' to set one.");
Console.WriteLine("incorrect password! access denied.");
Environment.Exit(1);
}


Console.WriteLine("access granted.");
}
else
{
Console.WriteLine("no password set. Use 'pass set' to set one.");
}

Console.WriteLine("type 'idk' for a list of commands."); // not a command, but it still triggers Commands.UnknownCommand

while (true)
{
// Main command loop
Console.WriteLine("type 'idk' for a list of commands."); // not a command, but it still triggers Commands.UnknownCommand
Console.Write($"\n{System.Environment.UserName}@{System.Environment.MachineName} $ ");
string command = Console.ReadLine();

Expand Down Expand Up @@ -58,9 +61,42 @@ static void Main()
Commands.RemovePassword();
break;

case "pass":
Commands.PassNoParam();
break;

case "dice":
Commands.RollDice();
break;

case "sd":
Commands.SelfDestruct();
break;

case "fortune":
Commands.Fortune();
break;

case "tellajoke":
Commands.TellAJoke();
break;

case "lag":
Commands.Lag();
break;

case "facts":
Commands.UselessFact();
break;

case "unicode":
Commands.PrintUnicodeChar();
break;

case "exit":
Console.WriteLine("goodbye!");
return;
Environment.Exit(0);
break;

default:
Commands.UnknownCommand();
Expand Down

0 comments on commit 1ba94b3

Please sign in to comment.