From a0fcdc83cbc2b440a5836313b2afd1a35698f5ef Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Tue, 12 Mar 2024 23:46:02 -0600 Subject: AƱade pruebas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/arg_parser.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/arg_parser.py') diff --git a/src/arg_parser.py b/src/arg_parser.py index c2db3bd..a5fdb40 100644 --- a/src/arg_parser.py +++ b/src/arg_parser.py @@ -1,4 +1,5 @@ import argparse +import sys AVAILABLE_COMMANDS_HELP_STRING = """Available commands: @@ -6,13 +7,24 @@ AVAILABLE_COMMANDS_HELP_STRING = """Available commands: 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. + delete-at n: delete row at nth position """ class ArgParser: - def __init__(self): + def __init__(self, args=sys.argv): 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 + self.args = self.parser.parse_args(args) + + @property + def file(self): + return self.args.f + + @property + def command(self): + return self.args.c + + def print_help(self): + self.parser.print_help() \ No newline at end of file -- cgit v1.2.3