pday 0.4 → 0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/pday.rb +30 -9
  2. metadata +1 -1
@@ -99,40 +99,61 @@ main do
99
99
  filepath=options['path']+entrydate+suffix+'.'+options['format']
100
100
  if File.file?(filepath)
101
101
  unless options[:force]
102
- puts "File already exists. Will use existing file."
102
+ if options[:verbose]
103
+ puts "File already exists. Will use existing file."
104
+ end
103
105
  else
104
- puts "File already exists, replacing it."
106
+ if options[:verbose]
107
+ puts "File already exists, replacing it."
108
+ end
105
109
  `echo '#{prepopulate(entrydate)}' > "#{filepath}"`
106
110
  end
107
111
  else
108
- puts "Creating new entry for: "+entrydate
112
+ if options[:verbose]
113
+ puts "Creating new entry for: "+entrydate
114
+ end
109
115
  `echo '#{prepopulate(entrydate)}' > "#{filepath}"`
110
116
  end
111
- unless options[:log]
112
- puts "Editing entry: #{filepath}"
113
- exec("#{options['editor']} '#{filepath}'")
117
+ if !options[:log]
118
+ if !options[:output]
119
+ if options[:verbose]
120
+ puts "Editing entry: #{filepath}"
121
+ end
122
+ exec("#{options['editor']} '#{filepath}'")
123
+ else
124
+ exec("cat #{filepath}")
125
+ end
114
126
  else
115
127
  # THE LOG OPTION IS ON SO JUST APPEND A LINE
116
128
  if options['log']!=''
117
- puts "Adding log entry to: #{filepath}"
129
+ if options[:verbose]
130
+ puts "Adding log entry to: #{filepath}"
131
+ end
118
132
  if options[:timestamp]
119
133
  options['log']=Time.new.strftime("%H:%M")+" "+options['log']
120
134
  end
121
- exec("echo '#{formatlog(options['log'])}' >> #{filepath}")
135
+ if options[:output]
136
+ addoutput="; cat #{filepath}"
137
+ else
138
+ addoutput=""
139
+ end
140
+ exec("echo '#{formatlog(options['log'])}' >> #{filepath}#{addoutput}")
122
141
  end
123
142
  end
124
143
  end
125
144
 
126
- version '0.3'
145
+ version '0.5'
127
146
  description 'Simple plain text diary management script.'
128
147
 
129
148
  on("-t FORMAT","--format","Set format suffix")
149
+ on("-o","--output","Output the log file instead of opening it")
130
150
  on("-f","--force","Replace any existing file instead of editing it")
131
151
  on("-s SUFFIX","--suffix","Add suffix to file name (before format suffix)")
132
152
  on("-e EDITOR","--editor","Set the editor, vim, emacs, nano, etc.")
133
153
  on("-d DATE","--date","Supply an explicit date (also y, yy, yyy, t) ")
134
154
  on("-l LOG","--log","Instead of opening file, add a single log line")
135
155
  on("-p","--timestamp","Add timestamp to single line log")
156
+ on("-v","--verbose","Show more information when executing")
136
157
 
137
158
 
138
159
  go!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pday
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: