cue/load: support absolute directory paths as package args
Previously, passing an absolute directory path like `/path/to/pkg` or
`$PWD` to commands such as `cue eval` or `cue export` failed with
"cannot use absolute directory ... as package path". Convert absolute
package arguments into relative paths rooted at the configured working
directory up front so the rest of the loading logic handles them as
ordinary local import paths.
The rewrite runs before splitting arguments into packages and files so
that Windows-style absolute paths like `C:\foo\bar` are handled
correctly; filetypes.IsPackage rejects them because of the drive-letter
colon, so without the early rewrite they were misclassified as files.
While here, consolidate the Windows-courtesy `\` to `/` rewrite in
the same loop, and clone the args slice so we do not mutate the
callers input when rewriting qualifiers or normalising paths.
Fixes #1908.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ic49c20e9e09e1e8ec67c5749053547152ee326ac
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1216356
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>