From afd4e795e3a7e7b34e0d3127f11c05c0e7a2fede Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Tue, 12 Mar 2024 12:02:59 -0600 Subject: Añade main.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 23 +++++++++++++++++++++++ src/arg_parser.py | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 main.py create mode 100644 src/arg_parser.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..d785261 --- /dev/null +++ b/main.py @@ -0,0 +1,23 @@ +import sys +from src.table import Table +from src.arg_parser import ArgParser + + +help_string = """CSV utils + Usage: + python main.py -f file -c COMMAND ATTRIBUTES + file: ubicación del archivo csv + + Comandos disponibles: + row-at n: imprimir fila en n + get-rows n: imprimir primeras n filas + insert "csv string": insertar fila. La fila debe contener exactamente 3 elementos. + search "lookup": buscar texto lookup en la tabla. + """ + + +def main(): + ArgParser() + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/src/arg_parser.py b/src/arg_parser.py new file mode 100644 index 0000000..c2db3bd --- /dev/null +++ b/src/arg_parser.py @@ -0,0 +1,18 @@ +import argparse + + +AVAILABLE_COMMANDS_HELP_STRING = """Available commands: + row-at n: print row at the nth position + get-rows n: print first n rows + insert "csv string": insert row at the end, the row must have exactly 3 elements. + search "lookup": search "lookup" in the table. + """ + + +class ArgParser: + def __init__(self): + self.parser = argparse.ArgumentParser() + self.parser.add_argument('-f', required=True, help='CSV file location') + self.parser.add_argument('-c', required=True, help=AVAILABLE_COMMANDS_HELP_STRING, nargs=2) + self.args = self.parser.parse_args() + print(self.args) \ No newline at end of file -- cgit v1.2.3