Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Option returning null with generator arguments #204

@Lioness100

Description

@Lioness100

I'm using generator arguments and the last option, --name, always returns null when I try to set it.

*args() {
  const member = yield {
    type: "memberMention",
    prompt: {
      start: "...",
      retry: "...",
    },
  };

  const playlist = yield {
    type: (message, phrase) =>
      Playlist.resolvePlaylist(phrase, message.client, member.id), // returns null or object
    match: "rest",
    prompt: {
      start: "...",
      retry: `...`,
    },
  };

  const name = yield {
    type: Argument.validate("string", (m, p, str: string) => str.length <= 20),
    match: "option",
    flag: ["--name", "-n"],
    default: playlist.title,
    prompt: {
      optional: true,
      retry: "Please limit the name to 20 letters and try again",
    },
  };

  return { member, playlist, name };
}

If I omit --name then it uses the set default and works fine. However, if I do use --name or -n, it returns null. This is also the case if I don't provide a string after the flag, or if I provide a string over 20 characters. There is no prompting.

Logging parsed.optionFlags at the bottom also returns an empty array.

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