[fpc-pascal] Freepascal CLI library

2018-01-13 Thread Darius Blaszyk
I'm working on a CLI application that allows the user to do some
configuration. During the process the user is presented with different
questions that need to be answered, before the configuration is written
to file. For convenience, the user is presented with default options as
well. Something like this:

--
Log files can be written to monitor the performance and debug the
application
> Please select whether you would like to write logs to file (y/n) [y]:
--

Is there a library available that can handle this kind of input from the
command line? Though not difficult to write something from scratch (I
already started on it), I feel like this has to be available already.
Anyone has a tip for me?

TIA!

Rgds, Darius___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Freepascal CLI library

2018-01-13 Thread wkitty42

On 01/13/2018 04:53 PM, Darius Blaszyk wrote:

Is there a library available that can handle this kind of input from the
command line? Though not difficult to write something from scratch (I already
started on it), I feel like this has to be available already. Anyone has a
tip for me?


not specific to CLI apps but are you, perhaps, thinking of CheckOptions and 
HasOption?


i have a CLI app that is basically a CustApp... CheckOptions allows to check 
command line options for short and long variations...


  eg: -h or --help

then options may or may not have parameters... if they have a parameter, they 
must always have a parameter...


so basically, there's tMyApplication.DoRun... inside there, i check for command 
line options via CheckOptions like the following snippet... it checks for 
options such as


  appname -?
  appname -h
  appname --help

the above are all for displaying command line help...

  appname -v
  appname --version

these two display the program version information...

  appname --diag

this is the only option for diagnostic information...

  appname -i 
  appname --input 

these two are for input filemask... you probably don't want to worry about the 
AppName part... i had to do that for something special in this program... i thin 
kto try to have the log file default to the application name unless otherwise 
specified with another command line option... i've trimmed things in this quick 
snippet...



// TMyApplication
procedure TMyApplication.DoRun;
var
  ErrorMsg: String;
  foo: string;
begin
  // quick check parameters
  ErrorMsg:=CheckOptions('?hvi:','help version diag input:');
  if ErrorMsg<>'' then begin
writeln('Parameter Error: ',ErrorMsg);
Terminate;
Exit;
  end;

//  AppName := 
StringReplace(ExtractFileName(ExeName),ExtractFileExt(ExeName),'',[]);

  foo := paramstr(0);
  AppName := StringReplace(ExtractFileName(foo),ExtractFileExt(foo),'',[]);
  // parse parameters
  if HasOption('?') or HasOption('h','help') then begin
WriteHelp;
Terminate;
Exit;
  end;
  if HasOption('v','version') then begin
WriteVersion;
Terminate;
Exit;
  end;

  ModeDIAG := HasOption('diag');  // diagnostic mode, show 
config and quit

  if HasOption('i','input') then  // input files mask
InFile := GetOptionValue('i','input')
  else
InFile := '*.txt';
[... blah blah blah ...]



--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list unless*
   *a signed and pre-paid contract is in effect with us.*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Freepascal CLI library

2018-01-13 Thread Darius Blaszyk

> not specific to CLI apps but are you, perhaps, thinking of CheckOptions and 
> HasOption?

No I do not look for commandline handling. Rather a CLI interaction library. 
Which allows to interact with the application during runtime. Similar to how 
sphinx-quickstart works for instance.

Rgds Darius
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Dot syntax for types?

2018-01-13 Thread Ryan Joseph
I remember I heard about a mode switch that requires "type groups” (what are 
these called btw?) to use a . and be prefixed. For example:

type
TGLType = (GL_FLOAT, GL_UNSIGNED_BYTE);


TGLType.GL_FLOAT would be the full name (note GL_FLOAT already is declared so I 
want the type to be explicitly TGLType.GL_FLOAT in all cases). I need to make 
some wrappers around OpenGL types and I thought this would be a nice way to do 
it instead of declaring a bunch of constants with prefixes but I just can’t 
remember how to handle that dot syntax (maybe it’s in the trunk under 
development). Thanks.

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal