diff --git a/Class/Options.cs b/Class/Options.cs
index 399251c..ec0fd70 100644
--- a/Class/Options.cs
+++ b/Class/Options.cs
@@ -7,7 +7,7 @@ public class GetOptions{
public uint Amount{get; set;}
}
- [Verb("shuffle", HelpText = "Shuffle the deck")]
+ [Verb("shuffle", HelpText = "Shuffle the deck.")]
public class ShuffleOptions{
[Value(0, MetaName = "type", MetaValue = "string", Required = false, Default = "riffle", HelpText = "What shuffle to perform.")]
public string Type{get; set;}
@@ -16,4 +16,10 @@ public class ShuffleOptions{
[Option('q',"quiet", HelpText = "Suppress stdout.")]
public bool Quiet{get; set;}
}
+
+ [Verb("reset", HelpText = "Reset deck to default.")]
+ public class ResetOptions{
+ [Option('q',"quiet", HelpText = "Suppress stdout.")]
+ public bool Quiet{get; set;}
+ }
}
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
index 8c5f617..c203b78 100644
--- a/Program.cs
+++ b/Program.cs
@@ -12,6 +12,7 @@ class Program{
static int Main(string[] args){
Directory.CreateDirectory(configPath);
TarotDeck deck = new TarotDeck();
+
if(File.Exists(filePath)){
deck.DeserializeDeck(filePath);
}else{
@@ -19,19 +20,26 @@ static int Main(string[] args){
File.WriteAllText(filePath, deck.SerializeDeck());
}
- Type[] types = {typeof(ShuffleOptions), typeof(GetOptions)};
+ Type[] types = {typeof(ShuffleOptions), typeof(GetOptions), typeof(ResetOptions)};
return Parser.Default.ParseArguments(args, types)
- .MapResult(
- (GetOptions options) => {
- options.Amount = Math.Max(1, options.Amount);
+ .MapResult(
+ (GetOptions options) => Get(options, deck),
+ (ShuffleOptions options) => Shuffle(options, deck),
+ (ResetOptions options) => Reset(options, deck),
+ errors => 1);
+ }
+
+ private static int Get(GetOptions options, TarotDeck deck){
+ options.Amount = Math.Max(1, options.Amount);
for (int i = 0; i < options.Amount; i++){
Console.WriteLine(deck.RequeueCard().ToString());
}
File.WriteAllText(filePath, deck.SerializeDeck());
return 0;
- },
- (ShuffleOptions options) => {
- options.Amount = Math.Max(1, options.Amount);
+ }
+
+ private static int Shuffle(ShuffleOptions options, TarotDeck deck){
+ options.Amount = Math.Max(1, options.Amount);
switch(options.Type.ToLower()){
case "riffle":
for (int i = 0; i < options.Amount; i++){
@@ -63,8 +71,13 @@ static int Main(string[] args){
}
File.WriteAllText(filePath, deck.SerializeDeck());
return 0;
- },
- errors => 1);
+ }
+
+ private static int Reset(ResetOptions options, TarotDeck deck){
+ deck.DeserializeDeck(defaultFilePath);
+ if(!options.Quiet) Console.WriteLine("The deck has been reset to default.");
+ File.WriteAllText(filePath, deck.SerializeDeck());
+ return 0;
}
}
-}
+}
\ No newline at end of file
diff --git a/tarot.csproj b/tarot.csproj
index 46d097e..cfbd8df 100644
--- a/tarot.csproj
+++ b/tarot.csproj
@@ -4,20 +4,15 @@
Exe
net5.0
oscarcederberg
+ Copyright (C) 2021 Oscar Cederberg
+This program comes with ABSOLUTELY NO WARRANTY; Check the GNU General Public
+License Version 3 (GPLv3) for more details. This is free software, and you are
+welcome to redistribute it under the GPLv3 terms and conditions.
+ 0.1.0
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-