+
Skip to content

Parse command arguments surrounded by quote marks as single argument #21

Open
@exodustx0

Description

@exodustx0

It'd be very useful if users can call commands with arguments that may contain spaces (or tabs), and have them be considered a single argument. Would love to do you a PR for this!

The way I see it, the way to go is: after getting stringArgs, iterate over it, pushing to an intermediate array, concatenating elements once an element starts with a quote mark until an element ends with a quote mark (or until the last element). I thought about incorporating all conditions into a single regular expression to do the splitting into stringArgs with, but after some experimentatoin I couldn't find a way to do that, but even if I did, it would likely end up very ugly (i.e. not very maintainable).

There is the question of which quote marks should be considered delimiters. Considering that this is for Discord, I'd argue that it makes sense to count backticks and triple-backticks along with the obvious double quotes. Thoughts?

I'd use this list as checklist for implementing this functionality, as it seems general enough.

PS: shouldn't arguments be split on both spaces and tabs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载