Skip to content

Commit

Permalink
Expand verbs, change namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarcederberg committed Jul 25, 2021
1 parent 1ee8fb9 commit cc1e118
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using tarot.Subscription;
using Subscription;

namespace tarot.Menu{
namespace MenuCLI{
public abstract class AbstractMenuEntry<T> : IMenuEntry, ISubscribable<T>{
protected string _text;
protected readonly List<ISubscriber<T>> _subscribers;
Expand Down
2 changes: 1 addition & 1 deletion Class/Menu/IMenu.cs → Class/MenuCLI/IMenu.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace tarot.Menu{
namespace MenuCLI{
public interface IMenu{
public void Up();
public void Down();
Expand Down
2 changes: 1 addition & 1 deletion Class/Menu/IMenuEntry.cs → Class/MenuCLI/IMenuEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace tarot.Menu{
namespace MenuCLI{
public interface IMenuEntry{
public string GetText();
public void Select();
Expand Down
3 changes: 2 additions & 1 deletion Class/Menu/ListMenu.cs → Class/MenuCLI/ListMenu.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using tarot;

namespace tarot.Menu{
namespace MenuCLI{
public class ListMenu : IMenu{
private IMenuEntry[] _entries;
private string _cursor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using tarot.Subscription;
using Subscription;

namespace tarot.Menu{
namespace MenuCLI{
public class MenuEntryFunc<T> : AbstractMenuEntry<T>{
private Func<T> _func;

Expand Down
2 changes: 1 addition & 1 deletion Class/Subscription/ISubscribable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace tarot.Subscription{
namespace Subscription{
public interface ISubscribable<T>{
public void Subscribe(ISubscriber<T> subscriber);
public void NotifySubscribers(T value);
Expand Down
2 changes: 1 addition & 1 deletion Class/Subscription/ISubscriber.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace tarot.Subscription{
namespace Subscription{
public interface ISubscriber<T>{
public void Notify(T value);
}
Expand Down
2 changes: 1 addition & 1 deletion Class/Subscription/Logging/AbstractLogger.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace tarot.Subscription.Logging{
namespace Subscription.Logging{
abstract class AbstractLogger<T> : ILogger<T>{
protected List<Log> _logs;
protected AbstractLogger(Log log = null){
Expand Down
2 changes: 1 addition & 1 deletion Class/Subscription/Logging/ActionLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace tarot.Subscription.Logging{
namespace Subscription.Logging{
class ActionLogger : AbstractLogger<bool>{
private string _onSuccess;
private string _onFailure;
Expand Down
2 changes: 1 addition & 1 deletion Class/Subscription/Logging/ILogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace tarot.Subscription.Logging{
namespace Subscription.Logging{
public interface ILogger<T> : ISubscriber<T>{
public void AddLog(Log log);
}
Expand Down
2 changes: 1 addition & 1 deletion Class/Subscription/Logging/Log.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace tarot.Subscription.Logging{
namespace Subscription.Logging{
public class Log{
private List<LogEntry> _entries;

Expand Down
2 changes: 1 addition & 1 deletion Class/Subscription/Logging/LogEntry.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace tarot.Subscription.Logging{
namespace Subscription.Logging{
public class LogEntry{
public DateTime Time;
public string Message;
Expand Down
2 changes: 1 addition & 1 deletion Class/Subscription/Logging/ValueLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace tarot.Subscription.Logging{
namespace Subscription.Logging{
class ValueLogger<T> : AbstractLogger<T>{
private string _onRetrieval;
public ValueLogger(string _onRetrieval, Log log = null) : base(log){
Expand Down
29 changes: 24 additions & 5 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public class GetOptions{
public class ShuffleOptions{
[Value(0, MetaName = "type", MetaValue = "string", Default = "riffle", HelpText = "What shuffle to perform.")]
public string Type{get; set;}
[Value(1, MetaName = "amount", MetaValue = "int", Default = 1, HelpText = "Number of shuffles to perform.")]
public int Amount{get; set;}
[Option('q',"quiet", HelpText = "Suppress stdout.")]
public bool Quiet{get; set;}
}

static int Main(string[] args){
Expand All @@ -32,21 +36,36 @@ static int Main(string[] args){
return 0;
},
(ShuffleOptions options) => {
options.Amount = Math.Max(1, options.Amount);
switch(options.Type.ToLower()){
case "riffle":
deck.ShuffleDeck(ShuffleType.Riffle);
for (int i = 0; i < options.Amount; i++){
deck.ShuffleDeck(ShuffleType.Riffle);
}
break;
case "overhand":
deck.ShuffleDeck(ShuffleType.Overhand);
for (int i = 0; i < options.Amount; i++){
deck.ShuffleDeck(ShuffleType.Overhand);
}
break;
case "fisheryates" or "perfect":
deck.ShuffleDeck(ShuffleType.FisherYates);
for (int i = 0; i < options.Amount; i++){
deck.ShuffleDeck(ShuffleType.FisherYates);
}
break;
default:
Console.WriteLine("Unkown shuffletype: {0}", options.Type.ToLower());
if (!options.Quiet){
Console.WriteLine("Unkown shuffletype: {0}.", options.Type.ToLower());
}
return 1;
}
Console.WriteLine("Performed {0} shuffle", options.Type.ToLower());
if (!options.Quiet){
if(options.Amount > 1){
Console.WriteLine("Performed {0} {1} shuffles.", options.Amount, options.Type.ToLower());
}else{
Console.WriteLine("Performed {0} shuffle.", options.Type.ToLower());
}
}
return 0;
},
errors => 1);
Expand Down

0 comments on commit cc1e118

Please sign in to comment.