Commit 6bba1561 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Move getopt functionality to superclass.

parent 90b16b67
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import getopt
class InvalidCommandArgument(Exception): class InvalidCommandArgument(Exception):
pass pass
...@@ -79,6 +81,14 @@ class Command(object): ...@@ -79,6 +81,14 @@ class Command(object):
return False return False
def getopt(self, p_flags):
try:
result = getopt.getopt(self.args, p_flags)
except getopt.GetoptError:
result = ([],self.args)
return result
def usage(self): def usage(self):
return "No usage text available for this command." return "No usage text available for this command."
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import getopt
import Command import Command
import Config import Config
import Filter import Filter
...@@ -32,10 +30,7 @@ class ListCommand(Command.Command): ...@@ -32,10 +30,7 @@ class ListCommand(Command.Command):
self.show_all = False self.show_all = False
def _process_flags(self): def _process_flags(self):
try: opts, args = self.getopt('s:x')
opts, args = getopt.getopt(self.args, 's:x')
except getopt.GetoptError:
return self.args
for o, a in opts: for o, a in opts:
if o == '-x': if o == '-x':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment