Skip to content

Command line interface (CLI) #135

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

Closed
milancurcic opened this issue Jul 21, 2020 · 11 comments · Fixed by #204
Closed

Command line interface (CLI) #135

milancurcic opened this issue Jul 21, 2020 · 11 comments · Fixed by #204

Comments

@milancurcic
Copy link
Member

How to implement the CLI in fpm-fortran? We can use:

  • Intrinsics command_argument_count and get_command_argument (lowest level, no dependencies)
  • FLAP by @szaghi (library, pure Fortran, I've used it a bit with good experience)
  • M_cli by @urbanjost (library, pure Fortran, no personal experience with it)
  • Some other library I'm not aware of?

I think we should go with a library and both FLAP and M_cli seem to do what we need (positional arguments + optional flags). What do you think?

@certik
Copy link
Member

certik commented Jul 21, 2020

I would go with FLAP. But we have to make it an fpm package first, so that we can use it as a dependency. Update: that actually might not be as easy without refactoring... Looking at M_cli, it actually seems much easier to create an fpm package out of it. So we might start with M_cli, and then if FLAP can be made an fpm package, we can switch to it.

@milancurcic
Copy link
Member Author

M_cli is already an fpm package (I tried it--it works). However, after reviewing M_cli in more detail, I'm quite strongly in favor of FLAP. It seems more mature and powerful while in my opinion having a simpler API.

@szaghi would you accept a PR to FLAP that would make it an fpm package? We'd make sure that your existing build systems (CMake, Make, Fobis) still work. This would require adding an fpm.toml file to the top-level directory, and some adjustments to module names or source file names, but otherwise it would be backward compatible from user's point of view. Best part, it would make FLAP part of a rapidly growing fpm ecosystem of packages.

@everythingfunctional
Copy link
Member

I haven't had a chance to look at either of the libraries, but that is definitely the way to go. We need to do whatever can help us bootstrap this faster.

Note: the command line for fpm is quite complicated; subcommands, flags that are only applicable for a subset of them, some flags which may be mutually exclusive, etc.

I think the first step, before we start implementing the command line interface is to clearly spec it out. Then we can pick a library and start implementing.

@ivan-pi
Copy link
Member

ivan-pi commented Jul 21, 2020

I am aware of two more libraries for command line interfaces:

  • command_args from @arjenmarkus
  • FTN_Getopt by Reinhold Bader (author of FGSL). I like the simplicity of this one (it is a single module). Unfortunately, the source code is not publicly available at the moment. I have a copy of the code and the author has indicated to me I can share it under GPL and the condition of preserving the authorship.

@certik
Copy link
Member

certik commented Jul 21, 2020

I would like all fpm dependencies to be MIT or BSD licensed, because we are linking everything statically into one executable, so GPL (and even LGPL) would prohibit us to license fpm under the MIT license.

@jvdp1
Copy link
Member

jvdp1 commented Jul 21, 2020

Wouldn't it be useful to integrate such a library first (or simultaneously) in stdlib?

@ivan-pi
Copy link
Member

ivan-pi commented Jul 21, 2020

One more library I learned of recently is libSUFR (libSUFR is a library containing Some Useful Fortran Routines). It is also GPL.

The M_cli module from @urbanjost is licensed under the Unlicense.

The way I understand the licensing system of FLAP:

for FOSS projects:
    GPL v3;
for closed source/commercial projects:
    BSD 2-Clause;
    BSD 3-Clause;
    MIT.

fpm would count as a FOSS project, since the source is public. Am I correct?

@milancurcic
Copy link
Member Author

fpm would count as a FOSS project, since the source is public. Am I correct?

I think that strictly only GPL family of software is FOSS. We are just OSS :)

I'm pretty sure that @szaghi meant "use whatever license you want". He can confirm this.

@certik
Copy link
Member

certik commented Jul 21, 2020

@jvdp1 yes, stdlib should have basic command line parsing, just like Python has it. But we can wait with stdlib's integration until we get more experience what API makes the most sense.

@ivan-pi
Copy link
Member

ivan-pi commented Jul 21, 2020

Just as an alternative idea, we could also wrap one of the many existing C and C++ libraries:

I think with the current Haskell version of fpm this would require a custom Makefile.

@certik
Copy link
Member

certik commented Jul 21, 2020

Yes, I investigated all options for C++, and most of them work, and I settled with using CLI11 for LFortran. Works great.

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

Successfully merging a pull request may close this issue.

6 participants