-
Notifications
You must be signed in to change notification settings - Fork 71
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
Document how to use Decline with Ammonite (specifically manually passing args) #270
Comments
The idea, at least, is that Concretely, if your code is intended to just be used from Ammonite, I'd skip the |
So the reason I am using Decline in Ammonite is that even though Ammonite has its own functionality for command line parsing which works great for more trivial use cases, Decline is much better for complex cases (i.e. creating I guess the thing is that Ammonite does actually expose a I understand that you can use Do you have a strong objection to removing the deprecation and just documenting clearly how its meant to be used? |
So JS is actually a great example, because that is supported by
Unfortunately, yes! In part because we used to do this and it was a significant maintenance burden, and in part because we need to make strong assumptions about the calling context of Turning this the other way... I would imagine that the way to do this without *App in ammonite would look something like: val app = Command(...) {
...
}
@main
def entrypoint(args: String*) = {
command.parse(args) match {
case Left(help) => exit(help)
case Right(_) =>
}
} Does that work in your case, or is there some important functionality that's not available outside of |
Sorry for the late response but I came across this problem in another context which alludes to your point
I have this situation which is that I actually want to test a I understand there may some deliberation when it comes to the ideal way to test an the |
So I am trying to use decline within Ammonite and there doesn't seem to be a good uesr guide on how to do this. From the docs on Ammonite, i.e. https://ammonite.io/#ScriptArguments you can access the command line arguments by doing the following
Assuming you have a an app
MyApp
as follows (taken from example)You would do something like this
The problem is that the
main
method inCommandApp
is apparently deprecated, i.e.Ontop of this the
command
variable inside theCommandApp
class is not publicly visible outside the class (its missing theval
modifier in the constructor) so its not like you can manually doMyApp.command.parse
(should this deprecated methodmain
be removed in the future). So how exactly is one meant to manually parseargs
to aCommandApp
without using the deprecatedmain
method? For example https://ben.kirw.in/decline/scalajs.html#ambient-arguments details how to get theargs
on various platforms but never how to pass it into aCommandApp
and the provided link at https://ben.kirw.in/decline/usage.html#defining-an-application details how you can manually useargs
when you have aCommand
but not when you have aCommandApp
(this goes to the previous problem where thecommand
inside theCommandApp
is not publicly visible).Conclusively I guess I also don't understand why the
CommandApp.main
method is deprecated, if you are using something like Ammonite it is by far the easiest way to make the repl/scripts work with an existingCommandApp
(which is the ideal way to use decline). This would also be the case for any other kind of dynamic repl/interactive session whereargs
are passed in a different way.The text was updated successfully, but these errors were encountered: