[fpc-pascal] getopts unit vs CustApp parameter handling

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Wed May 4 09:08:58 CEST 2016


On 2016-05-03 11:02, Michael Van Canneyt wrote:
> They serve the same purpose, but function differently.
> 
> Simply use the one whose interface you like best.

I'm used to the command line parameters handling of CustApp, but none of
my applications are TCustomApp based. Plus CustApp gives no code reuse
regarding command line parameters code. So I refactored the code out of
TCustomApp into an Interface and Class implementing that interface. So
now if I need good parameter list handling I simply mix in Interface
Delegation into any of my applications. This seems to work very well
thus far.

Would this be of interest to Free Pascal? If so, I can refactor the
CustApp code to use the Interface too.

If you wanted to take a look, the code is in the fpg_cmdlineparams.pas
unit in fpGUI. The ICmdLineParams interface and TfpgCmdLineParams class
(ignore the other deprecated class in that unit).


https://github.com/graemeg/fpGUI/blob/develop/src/corelib/fpg_cmdlineparams.pas

Example usage:
  See the nanoedit project in fpGUI:


https://github.com/graemeg/fpGUI/blob/develop/examples/apps/nanoedit/nanoedit.lpr

Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp



More information about the fpc-pascal mailing list