MoFEM CLI implementation

32 views
Skip to first unread message
Assigned to lik...@wp.pl by me

Preslav Aleksandrov

unread,
Sep 20, 2021, 5:41:01 AM9/20/21
to MoFEM Q&A
Quick question,

How do mofem modules handle command line inputs?

For continuity I want to use the same system so to speak. 

Also, for the windows executable we cant use getopt, so what do you think is best there?

Preslav Aleksandrov

unread,
Sep 20, 2021, 6:06:45 AM9/20/21
to MoFEM Q&A
Here is also the proposed usage:

mofem --module [module name] \        # sets the module we want
-- run [all module params go here] \     # passes the given params to the previously selected module
-- bc \                                                          # returns json string with the supported params for previously selected module
-- help # if module selected prints the module's help message
-m # same as module
-r   # same as run
-b  # same as bc
-h  # same as help

MoFEM Q&A

unread,
Sep 20, 2021, 6:24:20 AM9/20/21
to MoFEM Q&A
Hi,

Preslav, to manage command-line options we using PETSc interface. See, for example, https://petsc.org/release/docs/manualpages/Sys/PetscOptionsBegin.html

PETSc interface is written on top of getopt. What could be useful from your perspective, is that when you write, 

./prog -help

MOFEM/PETSc program will list you a list of the options. Now you can parse them. I imagine, that you can have some other tool, written in python, which will transform the output from -help about options into JSON and automatize input to FreeCAD.  

Lukasz

MoFEM Q&A

unread,
Sep 20, 2021, 7:47:05 AM9/20/21
to MoFEM Q&A
That makes sense.
Reply all
Reply to author
Forward
0 new messages