dartdoc does not support the `start-page` and `include-sdk` options so this fails on my system.  Perhaps it's better to put each version of the command into the if statement?  The big common part, `exclude-lib` can be assigned at the top (e.g. `EXCLUDE_LIB=js,metadata,…`) and used in both commands (e.g. `--exclude-lib=$EXCLUDE_LIB`).