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

Move getopt functionality to superclass.

parent 90b16b67
......@@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import getopt
class InvalidCommandArgument(Exception):
pass
......@@ -79,6 +81,14 @@ class Command(object):
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):
return "No usage text available for this command."
......
......@@ -14,8 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import getopt
import Command
import Config
import Filter
......@@ -32,10 +30,7 @@ class ListCommand(Command.Command):
self.show_all = False
def _process_flags(self):
try:
opts, args = getopt.getopt(self.args, 's:x')
except getopt.GetoptError:
return self.args
opts, args = self.getopt('s:x')
for o, a in opts:
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