Added About and License commandline keys
[findit] / src / main.py
index 69c3104..07dfb9e 100755 (executable)
@@ -19,7 +19,7 @@ class Control(object):
         self.abstrac = Abstraction()
 
         if(len(sys.argv) > 1):
-            Cli_Presentation()  ###
+            Cli_Presentation(self.abstrac)  ###
         else:
             Gtk_Presentation(config, self.abstrac)  ###
 
@@ -43,26 +43,36 @@ any later version.'
 
 class Cli_Presentation(object):
 
-    def __init__(self):
+    def __init__(self, abstrac):
         from optparse import OptionParser
+        import sys
+
+        self.abstrac = abstrac
 
-        parser = OptionParser()
+        parser = OptionParser(version=__progname__ + ' ' + __version__)
         parser.add_option('--search', '-s', dest='search', type='string')
         parser.add_option('--output', '-o', dest='output', type='string')
         parser.add_option('--params', '-p', dest='params', type='string')
+        parser.add_option('--about',   action='callback', callback=self._about)
+        parser.add_option('--license', action='callback', callback=self._license)
         (options, args) = parser.parse_args()
-#         print options
-#         print args
 
         config = {}
         config['search'] = options.search
         config['outtype'] = options.output
         config['ignore_dirs'] = ['/dev', '/proc', '/sys', '/mnt']
-        config['start_path'] = options.params.split(' ')[0]
-        config['count'] = options.params.split(' ')[1]
+        config['start_path'], config['count'] = options.params.split()
 
         self.show_search_toplevel(config)
 
+    def _about(self, *a):
+        print self.abstrac.comments
+        sys.exit()
+
+    def _license(self, *a):
+        print self.abstrac.license
+        sys.exit()
+
     def show_search_toplevel(self, config):
         search_module = __import__(config['search'] + '.search')
         search_toplevel = search_module.search.Control('cli', config).run()
@@ -147,10 +157,6 @@ class Gtk_Presentation(object):
         window.show_all()
         gtk.main()
 
-    def about_dialog(self, btn):
-        from about import About
-        About()
-
     #=== Search selecting =====================================================
     def show_search_toplevel(self, btn, searchtype):
         print 'Entering <' + searchtype + '> search mode...'