lib/standup_md/cli.rb in standup_md-0.1.3 vs lib/standup_md/cli.rb in standup_md-0.2.0

- old
+ new

@@ -1,7 +1,6 @@ require 'json' -require 'yaml' require 'optparse' require_relative '../standup_md' class StandupMD ## @@ -56,12 +55,17 @@ ## # Sets up an instance of +StandupMD+ and passes all user preferences. # # @return [StandupMD] def standup - @standup ||= ::StandupMD.new do |s| - echo 'Runtime options:' + cf = File.file?(PREFERENCE_FILE) ? PREFERENCE_FILE : nil + @standup ||= ::StandupMD.new(cf) do |s| + if s.config.any? + echo 'Config options:' + s.config.each { |k, v| echo " #{k} = #{v}" } + end + echo 'Runtime options:' if preferences.any? preferences.each do |k, v| echo " #{k} = #{v}" s.send("#{k}=", v) end end.load @@ -132,20 +136,20 @@ end ## # Opens the file in an editor. Abandons the script. def edit - echo " Opening file in #{editor}" + echo "Opening file in #{editor}" exec("#{editor} #{standup.file}") end ## # Writes entries to the file. # # @return [Boolean] true if file was written def write_file - echo ' Writing file' + echo 'Writing file' standup.write end ## # Should current entry be printed? If true, disables editing. @@ -293,9 +297,9 @@ @edit = false @write = false end end.parse!(options) - (File.file?(PREFERENCE_FILE) ? YAML.load_file(PREFERENCE_FILE) : {}).merge(prefs) + prefs end end end