Skip to content
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

Support build script arguments specified using UnionArgParser format #438

Closed
bentayloruk opened this issue May 26, 2014 · 8 comments
Closed

Comments

@bentayloruk
Copy link
Contributor

I've been running my FAKE build scripts directly via FSI, but after recent problems, am switching to using FAKE.exe (as I believe this is the right way to do it now). My build script was using UnionArgParser (a very nice arg parsing library) to specify and handle build script arguments. However, I don't think it is possible to make this work via FAKE.exe as it does it's own processing of the arguments.

From digging around, I'm assuming that one must use the -d: prefix on an argument to have it sent to FSI when the build script is executed. However, I would like to be able to send my current argument format (e.g. --config release) to FSI (as this is what UnionArgParser supports).

Is there a way to do this that I'm missing? If not, would you consider a PR that enabled this? I'm open to suggestions, but of the top of my head thought we could detect --fsiargs and then pass all args after that to FSI?

Update: I see I've misunderstood. The -d: arguments are passed as FSI options, rather than as arguments for the .fsx script. Everything else is set into EnvironmentVariables. Perhaps, a PR that supports an alternative to the arg=x syntax might work...

@bentayloruk bentayloruk changed the title Passing arguments to the build script using UnionArgParser Support build script arguments specified using UnionArgParser format May 26, 2014
@forki
Copy link
Member

forki commented May 27, 2014

https://github.com/fsharp/FAKE/blob/master/src/app/FAKE/Program.fs#L43 is the only way at the moment. But I'm open for (hopefully backwards compatible) changes,

@bentayloruk
Copy link
Contributor Author

OK, I will have a crack at it. fsi command line usage is specified as follows:

fsi.exe <options> [script.fsx [<arguments>]

The -d: arguments to fake.exe are used as the <options> for fsi. I am suggesting I add support for providing the <arguments>. Are you happy for me to have a crack at this?

I could not find documentation for the FAKE command line (bar this). Is there any? If not, I will write that up too.

@forki
Copy link
Member

forki commented May 27, 2014

yes I'm very happy if you could take this. I admit the command line options are a field where we need improvements and documentation.

Thanks a lot.

hq07e

@bentayloruk
Copy link
Contributor Author

Hmmm, did the -d: argument scheme to pass options to fsi ever work? The -d: is not stripped from the arg, so I don't see how it could match any of these options. Am I missing something? I assumed it was for doing something like -d:--quiet, but that the -d would be stripped off. Maybe I've missed the point...

@bentayloruk
Copy link
Contributor Author

I have found the issue. Someone asked for support for the --define or -d option. Support was added for this, but only this fsi option. Is this what you intended, or did you mean to pass through all fsi options?

@forki
Copy link
Member

forki commented May 28, 2014

I think it would be good to add all the fsi options. /cc @ctaggart

bentayloruk added a commit to bentayloruk/FAKE that referenced this issue May 28, 2014
…ne can fully specify the command line used by FAKE to invoke FSI. I required this as my build script uses UnionArgParser and there was no way for me to provide arguments to my build script in the format that I wanted. I hope this will be useful in other scenarios (like for those wishing to specify multiple FSI options).

* New switch implemented and previous usage left intact.
* Command line documentation written for existing switches and new usage.
* Add FsiArgs DU for more specific configuration of FSI invocation.
@bentayloruk
Copy link
Contributor Author

I've had an initial crack at this. Works for me, but would be great if you could have a look and tell me if you like the direction. I tried to add some docs for the command line too, including the new switch I added --fsiargs. It's in the commit referenced above and you can read it here.

I had to stop myself from pulling in UnionArgParser and cleaning up the FAKE argument processing code :).

@bentayloruk
Copy link
Contributor Author

OK. So I couldn't stop myself. I have a "better" solution for the FAKE cli in general in the works. Still keen to receive feedback on the --fsiargs solution as it will retain this option. I'm working on keeping backwards compatibility too.

bentayloruk added a commit to bentayloruk/FAKE that referenced this issue Jun 3, 2014
* New CLI for FAKE that uses UnionArgParser.
* If new CLI cannot parse, use old CLI for backwards compat.
* Strongly typed and easy to read and modify.
* Less brittle in face of changes needed for fsprojects#438 etc.
* Generates documentation.
* Supports combination with app.config settings.
* Support long and short switches (e.g. --version or -v).
* Support multi-values (e.g. --envVar key value --envVar key value).
* Make env flag switches explicit (i.e. --envFlag nameWhoseValWillBeTrue).
* Print old and new help.
@forki forki closed this as completed Jun 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants