Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Logging works now

  • Loading branch information...
commit 2e857bb5fb31cdafc1dcd1ccd7ca9396bf9972e8 1 parent 5a4bf93
Matthew Taylor authored September 19, 2012

Showing 1 changed file with 13 additions and 15 deletions. Show diff stats Hide diff stats

  1. 28  pom.ps1
28  pom.ps1
... ...
@@ -1,6 +1,6 @@
1 1
 param(
2 2
 	$goal,
3  
-	$shouldLog,
  3
+	[switch]$l,
4 4
 	$POMLOG = $env:pomlog,
5 5
 	[switch]$h
6 6
 )
@@ -35,9 +35,8 @@ $script_name = $MyInvocation.MyCommand.Name
35 35
 function print_status ($minutes) {
36 36
   clear
37 37
   $minutes_remaining=$(($time_in_minutes - $minutes))
38  
-  # $log_line=$(test -n "$logfile" && echo -n " ($logfile)" || echo -n "")
39  
-  # echo "Pomodoro$log_line: $minutes_remaining minutes remaining to complete: $goal"
40  
-  echo "Pomodoro: $minutes_remaining minutes remaining to complete: $goal"
  38
+  $log_line=$(if($logfile) { " ($logfile)" } else { "" })
  39
+  echo "Pomodoro$log_line: $minutes_remaining minutes remaining to complete: $goal"
41 40
   if ( $minutes_remaining -eq 5 ) {
42 41
       safe_say "$minutes_remaining minutes remaining in your pomadoro"
43 42
   }
@@ -49,10 +48,9 @@ function finish {
49 48
   $msg="$time_in_minutes minute pomodoro done at $(date) for: $goal"
50 49
   echo $msg
51 50
 
52  
-  # if [ ! -z $logfile ]
53  
-  # then
54  
-    # echo $msg >> $logfile
55  
-  # fi
  51
+  if ( $logfile ) {
  52
+    echo $msg >> $logfile
  53
+  }
56 54
 
57 55
   $break_msg="Pomadoro complete. Take a 5 minute break."
58 56
   echo $break_msg
@@ -66,7 +64,7 @@ function safe_say($text) {
66 64
 	$synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
67 65
 
68 66
 	# This line converts the text to speech
69  
-	$synthesizer.Speak($text)
  67
+	$synthesizer.SpeakAsync($text)
70 68
 
71 69
 }
72 70
 
@@ -105,25 +103,25 @@ function print_help {
105 103
 
106 104
 # Main function.
107 105
 function run_main {
108  
-  for($minute=1; $minute -le $time_in_minutes; $minute++){
109  
-    print_status $(($minute))
  106
+  1..$time_in_minutes | % {
  107
+    print_status $(($_))
110 108
     Start-Sleep -s 60
111 109
   }
112 110
   finish
113 111
 }
114 112
 
115 113
 # Parse options, and run main.
116  
-if ( $should_log -eq "-l" ) {
117  
-  if(File-Exists($POMLOG)) {
  114
+if ( $l ) {
  115
+  if($POMLOG) {
118 116
     $logfile=$POMLOG
119 117
   } else {
120  
-    $logfile=Path-Join($env:home, 'pom.log')
  118
+    $logfile=Join-Path $env:home 'pom.log'
121 119
   }
122 120
 }
123 121
 
124 122
 if($h -or $goal -eq "--help") {
125 123
   print_help 
126  
-  return 0
  124
+  return
127 125
 } else {
128 126
   run_main
129 127
 }

0 notes on commit 2e857bb

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