DavisVaughan · GitHub

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be tempted to move this earlier and do:

if (!has_dots && !has_from && !has_to) {
  return("dot")
}

That way I think you could simplify the comment (since it's now more obviously what the condition is) and then you have all the successes before the failure.

Or maybe I'd prefer a big if statement like this:

if (has_dots && (!has_from || !has_to)) {
  "dots"
} else if (!has_dots && !has_from && !has_to) {
  # fallback if no args supplied
  "dots"
} else if (!has_dots && has_from && has_to) {
  "from-to"
} else {
  cli::cli_abort("Either supply both from and to or ...")
}

That simplifies the error at the expense of making it less clear, but maybe that's ok?

(Not that this is really that important, but thought it would be fun to think it through since we've been talking about if statements)

Read the original on github.com ↗