# ==============================================================================
"""CSV_GRID :  display a csv file content in a text grid"""
# ==============================================================================
__author__  = "Philippe Blasi"
__version__ = "1.0"
__date__    = "2023-05-02"
__usage__   = """
User input : <filename> [filename ...]
App output : grid of the provided csv files"""
# ==============================================================================
from ezCLI import *
# ------------------------------------------------------------------------------
def csv_grid(name:str) -> str:
  """return the string grid for the given csv file name"""
  matrix = read_csv(name) # read whole content of file 'name'
  return grid(matrix)
# ------------------------------------------------------------------------------
def parser(command:str) -> str:
  """parse 'command' and return content of provided files formated as a grid"""
  names = parse(command); #inspect()
  if type(names) is str:
    return csv_grid(names)
  else:
    return '\n'.join(csv_grid(name) for name in names)
# ==============================================================================
if __name__ == '__main__':
  userloop(parser, "Enter <filename> [filename ...]")
# ==============================================================================
