Skip to content
This repository
Browse code

Closes #28 - Adds pausing to Giles.

  • Loading branch information...
commit 75b1fc640e18bc47435ddc4de7ac8397be212d69 1 parent 471e986
Kelly Elton kellyelton authored
3  src/Giles.Core/Watchers/SourceWatcher.cs
@@ -21,6 +21,7 @@ public class SourceWatcher : IDisposable
21 21 readonly GilesConfig config;
22 22
23 23 public List<FileSystemWatcher> FileWatchers { get; set; }
  24 + public bool Pause { get; set; }
24 25
25 26 public SourceWatcher(IBuildRunner buildRunner, IFileSystem fileSystem,
26 27 IFileWatcherFactory fileWatcherFactory, GilesConfig config)
@@ -84,7 +85,7 @@ void ResetBuildTimer()
84 85
85 86 public void RunNow()
86 87 {
87   - if (!buildRunner.Run())
  88 + if (Pause || !buildRunner.Run())
88 89 return;
89 90
90 91 var listener = GetListener.Invoke(config);
12 src/Giles/Program.cs
@@ -134,7 +134,7 @@ static void ConsoleSetup()
134 134
135 135 static InteractiveMenuOption[] GetInteractiveMenuOptions()
136 136 {
137   - return new[]
  137 + return new[]
138 138 {
139 139 new InteractiveMenuOption { HandlesKey = key => key == "?", Task = DisplayInteractiveMenuOptions },
140 140 new InteractiveMenuOption { HandlesKey = key => key == "i", Task = DisplayConfig },
@@ -146,6 +146,7 @@ static InteractiveMenuOption[] GetInteractiveMenuOptions()
146 146 new InteractiveMenuOption { HandlesKey = key => key == "e", Task = DisplayErrors },
147 147 new InteractiveMenuOption { HandlesKey = key => key == "f", Task = SetTestFilters },
148 148 new InteractiveMenuOption { HandlesKey = key => key == "h", Task = ClearTestFilters },
  149 + new InteractiveMenuOption {HandlesKey = key => key == "p", Task = TogglePause},
149 150 };
150 151 }
151 152
@@ -209,8 +210,14 @@ static void DisplayVerboseResults()
209 210 Console.WriteLine("Please run some tests first...");
210 211 }
211 212
  213 + static void TogglePause()
  214 + {
  215 + sourceWatcher.Pause = sourceWatcher.Pause != true;
  216 + Console.WriteLine(sourceWatcher.Pause ? "Pausing Giles" : "Resuming Giles");
  217 + }
  218 +
212 219
213   - static T GetUserValue<T>(string description, T defaultValue)
  220 + static T GetUserValue<T>(string description, T defaultValue)
214 221 {
215 222 Console.Write("Enter new value for {0} ({1}): ", description, defaultValue);
216 223 var newValue = Console.ReadLine();
@@ -259,6 +266,7 @@ static void DisplayInteractiveMenuOptions()
259 266 Console.WriteLine(" F = Set Test Filters");
260 267 Console.WriteLine(" H = Clear Test Filters");
261 268 Console.WriteLine(" Q = Quit");
  269 + Console.WriteLine(" P = Toggle Pause Giles");
262 270 Console.WriteLine();
263 271 }
264 272 }

0 comments on commit 75b1fc6

Please sign in to comment.
Something went wrong with that request. Please try again.