-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicit handling of paths in using directives #1098
Comments
@prolativ Thanks for reporting,
will be replaced to
and if you want to skip a special character, users should add and additional dollar
|
I wouldn't like to go too far but we should probably keep in mind that using this exact syntax could cause some complications if we wanted to have some kind of more general variable substitution in strings. E.g. we could support something like //> using value "fooVersion" "1.2.3"
//> using lib "org.foo::foo-a:${fooVersion}"
//> using lib "org.foo::foo-b:${fooVersion}" |
Also if we finally decide to use internal string interpolation we should make sure that it's well supported by IDEs so that it's properly highlighted and people don't get interpolation by accident when a bare string literal was expected. |
One thing to consider (although making things more complicated): should we allow some kind of (predefined and OS agnostic?) path variables, e.g. |
Hi @prolativ, starting from the next version of After internal discussion, we have decided to implement only the |
Is your feature request related to a problem? Please describe.
Some using directives take paths as arguments. These might be some directives specific to scala-cli itself or something that is passed further to some other tool (e.g. options passed to the compiler or a compiler plugin). When relative paths are used it might be unclear if the programmer's intent was to:
2a) treat the path as relative to the file in which the directive is located
2b) treat the path as relative to the root of the build (e.g.
foo/bar
forscala-cli run foo/bar
)2c) treat the path as relative to the current working directory (where
scala-cli
is run from)Describe the solution you'd like
To avoid the confusion, file paths in using directives could be represented with some special syntax distinct from bare string literals. This would make it clear whether a user meant
1
or2
. Potentially a distinction between the subcases of2
could be made if we find it useful to support all of them, although IMO it would be enough for most use cases to support only2a
.Taking #1072 as an example, the problematic directive
could be replaced with something like
although I'm not insisting on
${...}
as the proper syntax - this is just to show the concept.Then
${.}
would get substituted by scala-cli with the absolute path of the directory containing the file with the using directive (assuming we're considering2a
) and the option containing the absolute path would get passed to the compiler. Paths defined as quoted strings wouldn't be modified in any way.The example also shows that we would need some way to concatenate the resolved paths with some string literals to form proper options for the compiler or some other tool.
The text was updated successfully, but these errors were encountered: