Commits

Jason R. Coombs  committed 8accf47

Expand merchant processing to support multiple commands

  • Participants
  • Parent commits d1b332e

Comments (0)

Files changed (2)

File jaraco/financial/merchant.py

 import itertools
 import argparse
 
-from jaraco.util.itertools import is_empty, always_iterable
+import jaraco.util.logging
 from jaraco.util import ui
+from jaraco.util import cmdline
 from bs4 import BeautifulSoup
 import xlsxcessive.xlsx
+from jaraco.util.itertools import is_empty, always_iterable
 
 from . import ledger
 
 	@classmethod
 	def handle_command_line(cls):
 		parser = argparse.ArgumentParser()
+		jaraco.util.logging.add_arguments(parser)
+		cmdline.Command.add_subparsers(parser)
+		args = parser.parse_args()
+		args.action.run(args)
+
+class Import(cmdline.Command):
+	@classmethod
+	def add_arguments(cmd, parser):
 		parser.add_argument('filename')
-		args = parser.parse_args()
-		portfolio = cls.load()
+
+	@classmethod
+	def run(cls, args):
+		portfolio = Portfolio.load()
 		with open(args.filename, 'rb') as pfb:
 			tl_report = TranslinkReport.load(pfb)
 			portfolio.import_(tl_report)
 	},
 	install_requires=[
 		'keyring',
-		'jaraco.util>=6.3',
+		'jaraco.util>=6.3.1',
 		'path.py',
 		'ofxparse',
 	] + argparse_req + dateutil_req,