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

Explicitly specifying cwd does not work as described in the document #234

Closed
lastland opened this Issue Sep 15, 2015 · 8 comments

Comments

Projects
None yet
2 participants
@lastland

lastland commented Sep 15, 2015

In the document it says you can specify current working directory like this:

%(cwd) ls 

What I've actually got is:

Welcome to the Ammonite Repl 0.4.7
(Scala 2.11.7 Java 1.8.0_40)
@ import ammonite.ops._
import ammonite.ops._
@ %(cwd) ls
Compilation Failed
Main.scala:93: could not find implicit value for parameter wd: ammonite.ops.Path
%(cwd) ls
 ^

With implicit wd imported, it will be:

@ import ammonite.ops.ImplicitWd._
import ammonite.ops.ImplicitWd._
@ %(cwd) ls
Compilation Failed
Main.scala:110: value ls is not a member of Int
%(cwd) ls
       ^
@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Sep 22, 2015

Looks like it rotted because the example wasn't taken from a unit test, shouldn't be too hard to fix it and keep it working in future

@lastland

This comment has been minimized.

lastland commented Oct 10, 2015

How do you plan to make it work with features like "invoking files"?

%(cwd/'other) cwd/'something%(args) or cwd/'something%(cwd/'other)? The first one looks quite strange with two %s. The latter one looks better, but how do you tell whether cwd/'other is the working directory or an argument?

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Nov 16, 2015

Haven't quite figured it out yet; probably will change the syntax in the next major version

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Nov 23, 2015

This will be fixed by (the poorly named commit) c67d59a. The "final" syntax will be

%(cwd/'other, args)

@lihaoyi lihaoyi closed this Nov 23, 2015

@lastland

This comment has been minimized.

lastland commented Nov 23, 2015

Thanks for the fix! I see that you can now use %.ls()(cwd) to explicitly declare the working directory, but I'm still not sure what it will be like, say, invoking a program from wd1 at wd2?

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Nov 23, 2015

@lastland you'd so something like

%.apply(wd1/'program1, args)(wd2)

It's kinda annoying you have to do the explicit .apply thing, but that's Scala for you.

You could also make wd2 implicit and it'll get picked up automatically

@lastland

This comment has been minimized.

lastland commented Nov 23, 2015

Thanks! I see. 😄

Do you think if this usage should be tested or documented as well? I understand that wd2 can be made implicit (and I like that design very much) but in some cases it may be easier to explicitly specify one.

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Nov 23, 2015

Yeah it should be... I'll go do that now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment