From 1f937b4053ab9cea593dc2ae8778d5abf3d9e36f Mon Sep 17 00:00:00 2001 From: Marcos Huerta Date: Tue, 27 Jul 2021 20:33:47 -0400 Subject: [PATCH] change print, change no argument behavior --- gpxcsv/__init__.py | 2 +- gpxcsv/__main__.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gpxcsv/__init__.py b/gpxcsv/__init__.py index 7fcc155..f7b44bb 100644 --- a/gpxcsv/__init__.py +++ b/gpxcsv/__init__.py @@ -153,7 +153,7 @@ def _list_to_csv(self, list_of_dicts, csv_file): for row in list_of_dicts: mywriter.writerow(row) self._check_verbose_print( - f"CSV {csv_file} written with {len(list_of_dicts)} rows", + f"CSV {csv_file} written to {csv_file} with {len(list_of_dicts)} rows", force=True) if self.verbose: #leaving this in an if statement because of the column formatting for now diff --git a/gpxcsv/__main__.py b/gpxcsv/__main__.py index 77c3ed5..d84a6b9 100644 --- a/gpxcsv/__main__.py +++ b/gpxcsv/__main__.py @@ -1,11 +1,20 @@ import glob import argparse +import sys + from . import GpxCSV +class MyParser(argparse.ArgumentParser): + def error(self, message): + sys.stderr.write('error: %s\n' % message) + self.print_help() + sys.exit(2) + + def main(): """Main function for command line utility""" - parser = argparse.ArgumentParser() + parser = MyParser() parser.add_argument( 'input_file', nargs='+',