<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,43 +2,28 @@
 from __future__ import with_statement
 import commands
 import time
+import sys
 from optparse import OptionParser
 
-def parse_setup():
-	parser = OptionParser()
-	parser.add_option(&quot;-u&quot;, &quot;--user&quot;, action=&quot;store&quot;, type=&quot;string&quot;, 
-		dest=&quot;username&quot;, help=&quot;MySQL user name&quot;, metavar=&quot;USER&quot;)
-	parser.add_option(&quot;-h&quot;, &quot;--hostfile&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
-		dest=&quot;hostfile&quot;, help=&quot;Location of hosts.yak.&quot;, metavar=&quot;HOSTFILE&quot;)
-	parser.add_option(&quot;-d&quot;, &quot;--destpath&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
-		dest=&quot;destpath&quot;, help=&quot;Destination path on the remote server.&quot;, metavar=&quot;DESTPATH&quot;)
-	parser.add_option(&quot;-a&quot;, &quot;--archiver&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
-		dest=&quot;archiver&quot;, help=&quot;What archiver to use. Default is tar.&quot;, metavar=&quot;ARCHIVER&quot;)
-	parser.add_option(&quot;-o&quot;, &quot;--archiveroptions&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
-		dest=&quot;archiver_options&quot;, help=&quot;Special options to pass to the archiver.&quot;, metavar=&quot;ARCHIVEROPTIONS&quot;)
-	parser.add_option(&quot;-c&quot;, &quot;--compresser&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
-		dest=&quot;compress_app&quot;, help=&quot;What type of compression to use. Defaults to bzip2.&quot;, metavar=&quot;COMPRESSOR&quot;)
-	if not sys.argv[1:]:
-		parser.print_help()
-		exit(2)
-	(options, arg) = parser.parse_args()
-	return (options, arg)
+DEFAULTS = {'user': 'timeyak', 'hostfile': 'hosts.yak', 'dest_path': '/home/timeyak/backup/', 'archiver': 'tar', 
+	'archiver_options': 'cf', 'archiver_ext': '.tar', 'compress_app': 'bzip2', 'compress_ext': '.bz' }
 
 class YakDump:
 	
-	def __init__(self, user='timeyak', hostfile='hosts.yak', dest_path='/home/timeyak/backup/', archiver_options='-cf', archiver='tar', archiver_ext='.tar', compress_app='bzip2', compress_ext='.bz'):
+	def __init__(self, options):
 		print('timeyak waits for noman')
 		current_time = time.localtime()
 		self.time_str = str(current_time[0]) + str(current_time[1]) + str(current_time[2])
-		self.compress_app = compress_app
-		self.compress_ext = compress_ext
-		self.archiver = archiver
-		self.archiver_ext = archiver_ext
-		self.archiver_options = archiver_options
-		self.hostfile = hostfile
-		self.user = user
 		self.files = []
-		self.dest_path = dest_path
+		self.compress_app = options.user if options.user else DEFAULTS['compress_app']
+		self.archiver = options.archiver if options.archiver else DEFAULTS['archiver']
+		self.archiver_options = options.archiver_options if options.archiver_options else DEFAULTS['archiver_options']
+		self.hostfile = options.hostfile if options.hostfile else DEFAULTS['hostfile']
+		self.user = options.user if options.user else DEFAULTS['user']
+		self.dest_path = options.dest_path if options.dest_path else DEFAULTS['dest_path']
+
+		self.compress_ext = DEFAULTS['compress_ext'] #@todo: need this to check compress_app and pick based on that
+		self.archiver_ext = DEFAULTS['archiver_ext']
 
 	def get_hosts(self):
 		with open(self.hostfile) as f:
@@ -73,6 +58,28 @@ class YakDump:
 				c = 'scp ' + file + ' ' + self.user + '@' + host + ':' + self.dest_path
 				ret = commands.getstatusoutput(c.replace(&quot;\n&quot;, &quot;&quot;))
 
-yakdump = YakDump()
-yakdump.dump_files('/home/timeyak/test/')
-yakdump.copy_files()
+def parse_setup():
+	parser = OptionParser()
+	parser.add_option(&quot;-u&quot;, &quot;--user&quot;, action=&quot;store&quot;, type=&quot;string&quot;, 
+		dest=&quot;user&quot;, help=&quot;timeyak user name&quot;, metavar=&quot;USER&quot;)
+	parser.add_option(&quot;-f&quot;, &quot;--hostfile&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
+		dest=&quot;hostfile&quot;, help=&quot;Location of hosts.yak.&quot;, metavar=&quot;HOSTFILE&quot;)
+	parser.add_option(&quot;-d&quot;, &quot;--destpath&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
+		dest=&quot;dest_path&quot;, help=&quot;Destination path on the remote server.&quot;, metavar=&quot;DESTPATH&quot;)
+	parser.add_option(&quot;-a&quot;, &quot;--archiver&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
+		dest=&quot;archiver&quot;, help=&quot;What archiver to use. Default is tar.&quot;, metavar=&quot;ARCHIVER&quot;)
+	parser.add_option(&quot;-o&quot;, &quot;--archiveroptions&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
+		dest=&quot;archiver_options&quot;, help=&quot;Special options to pass to the archiver.&quot;, metavar=&quot;ARCHIVEROPTIONS&quot;)
+	parser.add_option(&quot;-c&quot;, &quot;--compresser&quot;, action=&quot;store&quot;, type=&quot;string&quot;,
+		dest=&quot;compress_app&quot;, help=&quot;What type of compression to use. Defaults to bzip2.&quot;, metavar=&quot;COMPRESSOR&quot;)
+	(options, arg) = parser.parse_args()
+	return (options, arg)
+
+def main():
+	(options, arg) = parse_setup()
+	yakdump = YakDump(options)
+	yakdump.dump_files('/home/timeyak/test/')
+	yakdump.copy_files()
+
+if __name__ == &quot;__main__&quot;:
+	main()</diff>
      <filename>timeyak.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a41a640c925b121f80c9c44f7f45342fcffe6470</id>
    </parent>
  </parents>
  <author>
    <name>Michael Matuzak</name>
    <email>michael@lambdaphant.com</email>
  </author>
  <url>http://github.com/emkay/timeyak/commit/e8e6e9db78e28a75db9e82f0a6d2e9a0f5b1de9d</url>
  <id>e8e6e9db78e28a75db9e82f0a6d2e9a0f5b1de9d</id>
  <committed-date>2009-05-07T17:12:32-07:00</committed-date>
  <authored-date>2009-05-07T17:12:32-07:00</authored-date>
  <message>moving around parsing function, making a main function, passing in cl args to the class, and setting up defaults</message>
  <tree>a8f45033a94ac40e5787dccedf68ed911f04c653</tree>
  <committer>
    <name>Michael Matuzak</name>
    <email>michael@lambdaphant.com</email>
  </committer>
</commit>
