Most interpreters/compilers for various languages only need a string (or a file… which is a string) to generate executable code/to interpret the code.
So… a better way would be to use a tokenizer for taking apart the command string, just like actual programming languages do. After that one could convert the resulting tokens (strings, numbers and operators) into an Abstract-Syntax-Tree for further processing, or directly execute the tokens. The latter option is actually easier here, because many commands have different parameters, in different orders and amounts, which makes building an AST pretty complicated if not impossible (its also easier to extend).
Does that answer your question?