# HG changeset patch # User Luke Mewburn # Date 1585547191 -39600 # Node ID ae76ea63ee12a2082cd2f64811a8bedc7cf351c1 # Parent a89913941dcfc599ce9f7b23361a127b23dd8396 csv_to_fd: improve comments and usage diff -r a89913941dcf -r ae76ea63ee12 contrib/tools/csv_to_fd --- a/contrib/tools/csv_to_fd Mon Mar 30 15:31:48 2020 +1100 +++ b/contrib/tools/csv_to_fd Mon Mar 30 16:46:31 2020 +1100 @@ -10,6 +10,7 @@ - Name: AVP Name. String, validated as ALPHA *(ALPHA / DIGIT / "-") per RFC 6733 section 3.2. + May start with a DIGIT (e.g., "3GPP-IMSI"). - Code: AVP Code. Integer, 0..4294967295. - Section: @@ -20,7 +21,7 @@ - RFC 6733 section 4.3 - RFC 7155 section 4.1 - Must, May, ShouldNot, MustNot: - Flags, possibly comma or space separated: M, V + Flags, possibly comma or space separated: M, P, V - Comment row. First cell: # Comment text 'Comment text' @@ -182,7 +183,7 @@ class Processor(object): - """Interface for processor of Avp""" + """Interface for processor of Avp.""" __metaclass__ = abc.ABCMeta @@ -226,7 +227,7 @@ class DebugProcessor(Processor): - """Display the CSV parsing""" + """Display the CSV parsing.""" def next_file(self, filename): print('File: {}'.format(filename)) @@ -243,7 +244,7 @@ class NoopProcessor(Processor): - """Validate the CSV; no other output""" + """Validate the CSV; no other output.""" def next_file(self, filename): pass @@ -259,7 +260,7 @@ class FdcProcessor(Processor): - """Generate freeDiameter C code + """Generate freeDiameter C code. Comment cells are parsed as: # text comment /* text comment */ @@ -374,7 +375,7 @@ class JsonProcessor(Processor): - """Generate freeDiameter JSON object + """Generate freeDiameter JSON object. """ def __init__(self): @@ -460,8 +461,9 @@ # Parse options parser = MyParser( + usage='%prog [-h] [-p PROCESSOR] FILE ...', description="""\ -Convert CSV files containing RADIUS or Diameter AVP tables +Convert CSV files FILE ... containing RADIUS or Diameter AVP tables into various formats using the specified processor PROCESSOR. """) @@ -472,13 +474,13 @@ ', '.join(processors.keys()))) (opts, args) = parser.parse_args() if len(args) < 1: - parser.error('Incorrect number of arguments') + parser.error('Incorrect number of arguments. Use -h for help.') # Find processor try: avpproc = processors[opts.processor]() except KeyError as e: - parser.error('Unknown processor "{}"'.format(opts.processor)) + parser.error('Unknown processor "{}".'.format(opts.processor)) # dict of [vendor][code] : Avp avp_codes = collections.defaultdict(dict)