Commits

Richo Healey committed fa0db27

Finish catching everything for --set

  • Participants
  • Parent commits 8069bee

Comments (0)

Files changed (4)

 twat -l should dump colors to terminal (This should be configurable tho)
 
 Refactor tweet printing code, unify throughout
+
+MIGRATIONS
+==========
+
+Shouldn't run if config is up to date
       rescue NoConfigFile
         puts "No config file, create one with twat -a [user|nick]"
         opts.usage
+      rescue InvalidSetOpt
+        puts "There is no such configurable option"
+        opts.usage
+      rescue RequiresOptVal
+        puts "--set must take an option=value pair as arguments"
       rescue InvalidCredentials
         puts "Invalid credentials, try reauthenticating with"
         puts "twat -a #{opts[:account]}"

lib/twat/actions.rb

       end
     end
 
-    def setopt
+    def setoption
       k, v = opts[:optval].split("=")
       raise RequiresOptVal unless v
       options = Options.new
       puts "twat: #{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_PATCH}"
     end
 
-    def method_missing
+    def method_missing(sym, *args, &block)
       raise NoSuchCommand
     end
 

lib/twat/options.rb

 
     # A set of wrappers around the global config object to set given attributes
     # Catching failures is convenient because of the method_missing? hook
-    def method_missing
+    def method_missing(sym, *args, &block)
       raise InvalidSetOpt
     end
 
     # withing the method_missing method, but that will just lead to nastiness
     # later when I implement colors, for example.
     def default=(value)
-      unless config.accounts.include?(opts[:account])
+      val = value.to_sym
+      unless config.accounts.include?(val)
         raise NoSuchAccount
       end
 
-      config[:default] = value
+      config[:default] = val
       config.save!
     end