metrumresearchgroup / bbi

Next generation modeling platform
11 stars 2 forks source link

reclean: avoid index error if no positional argument is specified #276

Closed kyleam closed 1 year ago

kyleam commented 1 year ago

This small PR fixes the following error that I noticed when looking into another issue:

$ bbi nonmem reclean
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
[...]

With this PR, that becomes

$ bbi nonmem reclean
Error: must specify one positional argument, a directory
Usage:
  bbi nonmem reclean [flags] <directory>

Flags:
[...]

It also fixes the more general issue of bbi double printing errors messages for RunE commands (mentioned in https://github.com/metrumresearchgroup/bbi/pull/272#discussion_r932278348)

Note that this PR uses gh-272 as the base, so this shouldn't be merged before that PR. That was done just to piggyback off of its last commit (e1e1bda) that quiets the linter (the tests from the PR trigger the same issue independently).