registermatch :: CliOpts -> Journal -> IO ()
registermatch opts@CliOpts{rawopts_=rawopts,reportspec_=rspec} j =
  case listofstringopt "args" rawopts of
    [desc] -> do
        let ps = [p | (_,_,_,p,_) <- postingsReport rspec j]
        case similarPosting ps desc of
          Nothing -> putStrLn "no matches found."
          Just p  -> TL.putStr $ postingsReportAsText opts [pri]
                     where pri = (Just (postingDate p)
                                 ,Nothing
                                 ,tdescription <$> ptransaction p
                                 ,p
                                 ,nullmixedamt)
    _ -> putStrLn "please provide one description argument."

-- Identify the closest recent match for this description in the given date-sorted postings.
registermatch :: CliOpts -> Journal -> IO ()
registermatch opts@CliOpts{rawopts_=rawopts,reportspec_=rspec} j =
  case listofstringopt "args" rawopts of
    [desc] -> do
        let ps = [p | (_,_,_,p,_) <- postingsReport rspec j]
        case similarPosting ps desc of
          Nothing -> putStrLn "no matches found."
          Just p  -> TL.putStr $ postingsReportAsText opts [pri]
                     where pri = (Just (postingDate p)
                                 ,Nothing
                                 ,tdescription <$> ptransaction p
                                 ,p
                                 ,nullmixedamt)
    _ -> putStrLn "please provide one description argument."

-- Identify the closest recent match for this description in the given date-sorted postings.
registermatch opts@CliOpts{rawopts_=rawopts,reportspec_=rspec} j =
  case listofstringopt "args" rawopts of
    [desc] -> do
        let ps = [p | (_,_,_,p,_) <- postingsReport rspec j]
        case similarPosting ps desc of
          Nothing -> putStrLn "no matches found."
          Just p  -> TL.putStr $ postingsReportAsText opts [pri]
                     where pri = (Just (postingDate p)
                                 ,Nothing
                                 ,tdescription <$> ptransaction p
                                 ,p
                                 ,nullmixedamt)
    _ -> putStrLn "please provide one description argument."

-- Identify the closest recent match for this description in the given date-sorted postings.