-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
CLAs vs options #36
Comments
I am reading with smartphone, thus I cannot read your references, later at ofgice I will investigate in more details. Anyhow, most part of your example is supported.
Is the For the special |
Ok, I find 5 minutes... If I understand right, you are distinguishing between:
Presently in FLAP there are:
For example: foo 2 7 8 --named 1 --verbose means that If I understand your issue, you are searching for a new (for FLAP) logic that when the special option foo 2 7 8 --named 1 --verbose -- file1.f90 ~/my_special_path/pearl_jam.mp3 the_caos.pdf Is my guess right? If not, please give me a minimal working example of what you are searching for. |
Yes, that is exactly what I am after some “final positional arguments” and there needs to be a way to iterate over them. This could be to query how many of them there are so that the user can extract them in a loop, or an iterator method allowing you to get the next one. Querying the number would be more useful for me, though, since the number doesn’t change once the program execution begins. Typically the |
mmm, for the iteration/numbers-counting there is no problem: it is very simple to return to the user an array (of strings) dimensioned at runtime over which the user can loop. On the contrary, if the |
Well, I'd be perfectly happy for it to be mandatory |
@zbeekman Ok, I first will try with mandatory |
I like your new profile image! Is that a numerical schlieren of a simulation computed with your OFF code? |
Yes Sherlock! It represents an instant of the starting transient of an highly under-expanded (I do not remember but should be Mach 6) jet. It should be a multispecies flow (jet lighter than ambient) simulated with a modified WENO-positivity-preserving scheme. |
Done (v0.6.0). Now you can pass your options (named and/or positional) and finally put a foo 231 -i pippo -- foo.f90 bar/baz.f90 pluto-giove.dat 2 313
^ ^ ^
positional | named | garbage Indeed the garbage could (in theory) appears everywhere, not only as trailing garbage. To retrieve the eventual garbage you must use the new This is a new feature, thus a lot of bugs could have been introduced. ASAP you tested this, feel free to submerge me of issues for bug-fix :-) Thank you @zbeekman |
Oh no, I just see you PRs now... this is a good time for using your merging suggestions... |
@zbeekman help!!!! After trying to push the new v0.6.0 I gotten: Counting objects: 26, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (26/26), done.
Writing objects: 100% (26/26), 7.55 KiB | 0 bytes/s, done.
Total 26 (delta 17), reused 0 (delta 0)
To git@github.com:szaghi/FLAP.git
* [new tag] v0.6.0 -> v0.6.0
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:szaghi/FLAP.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details. What I have to do? |
@szaghi run |
sorry… on my system |
thank you, I see checkout. However, the git diff list the effectively differences, but master is more up-to-date than origin/master. What happen if I do a |
OK, so you never showed me what command you actually ran when pushing your tag when you listed the output, but whatever |
circling back to the original topic, I took a look at the implementation and it looks good! My only objection is calling the stuff after |
:-) I think that garbage is used only into the test driver, the user can name it also critical :-) Anyhow, implementing it I have added some new other features ( |
Does FLAP have any notion of command line arguments vs command line options? See for example https://en.wikipedia.org/wiki/Getopt#Shell and the links from there, http://www.bahmanm.com/blogs/command-line-options-how-to-parse-in-bash-using-getopt, and
man getopt
.I often want to have a program that takes some optional flags, that might have arguments, but then a list of files, directories, etc just passed as white space separated strings. Also the special
--
denotes the end of options so you can pass an argument that looks like an option but is actually treated as an argument. (I use shell globbing and brace expansion to construct lists of stuff to process.) For example I have a code that will take ascii tecplot data files, each one corresponding to a flow snapshot, and average them across snapshots. The code might have some options to specify different behaviors but then takes a list of files to average as the rest of the arguments. After the options are processed there are an arbitrary number of positional arguments. Looking through the documentation I can’t figure out whether FLAP already supports this usage case, and if so, how one would tell FLAP to loop over the remaining arguments not corresponding to option flags/switches.I would be invoking such a program like this:
process_things --working-dir=../path/to/data --no-zones -- *H 0{0..2}{0..9}{0,5}h
The stuff between
process_things
and--
(which in this case is pretty much optional unless the shell glob*H
expands to something that looks like an option, say-fooH
or something like that) are flags/options to modify the behavior. These are the type of things FLAP already handles and handles well. (The=
syntax isn’t required; I don’t know whether FLAP supports this already or not, a space would be fine instead of=
) Then after the program processes the options, and sets default values etc. a loop is run over the remaining CLAs which are expanded by the shell via globbing or brace expansion etc. or from the output of some other command likeprocess_things -v --working-dir=../path/to/data/ -- $(command_to_generate_remaining_args)
I have some code that kinda-sorta emulategetopt
but FLAP does a lot of it much better.The text was updated successfully, but these errors were encountered: