examples icon indicating copy to clipboard operation
examples copied to clipboard

Dataroast Commands not properly accepting arguments

Open TomJDonahue opened this issue 1 year ago • 1 comments

There is an issue in the command.py file of the dataroast folder. When calling from_string, the parsed_args variable never gets added to if the args only contains strings. I added the else block, and the function now works appropriately.

Note, the merge command (which the 'if "," in arg:' line is attempting to solve for) still doesn't work properly.

` def from_string(command: str) -> "Command": parts = command.split() cmd, raw_args = parts[0], parts[1:]

    # Process each argument, converting to appropriate type
    parsed_args: list[str | int | list[str]] = ['' for arg in raw_args]
    for i, arg in enumerate(raw_args):
        try:
            if "," in arg:
                parsed_args[i] = arg.split(",")
            elif arg.isnumeric():
                parsed_args[i] = int(arg)
            else:
                parsed_args[i] = arg
        except ValueError:
            pass

    if not cmd_exists(cmd):
        raise ValueError(f"Command {cmd} does not exist.")
    return Command(cmd, parsed_args)

`

TomJDonahue avatar Dec 17 '24 14:12 TomJDonahue

I also had to prepopulate the parsed_args with a list comp or else I was getting index out of bounds errors.

TomJDonahue avatar Dec 17 '24 14:12 TomJDonahue