I think I figured it out..
I was trying:
MyProgram BadParm
Instead of
MyProgram --BadParm
or
MyProgram -b
Since this the base CLI template, initially, only h and help are allowed so the above should indeed give errors.
Trying with --BadParm I get something that makes sense:
Exception at 0000000000000000: Exception:
Invalid option at position 1: "badparm".Is there a way to customize that error? Ideally would like to show just:
Invalid option at position 1: "badparm"I think I will end up with
ErrorMsg:=CheckOptions('h', 'help');
if ErrorMsg<>'' then begin
ShowException(Exception.Create(ErrorMsg));
WriteHelp
Terminate;
Exit;
end;
it completely eludes me what the actual question is. (i'm probably not awake enough)
Much more likely my question was just confusing.
Hopefully I will get better at both Pascal/Lazarus and asking questions.
Doing an open source utility on my spare time which I will present to my boss to see if we use it at work.
Although several people, specially on reddit, were asking why on earth I would want to start learning Pascal.. trying Lazarus reminds me of how much I enjoyed working with Delphi many years back. Although I am no longer a developer, DBA now, I still find it very enjoyable to work on Pascal/Lazarus. It has been 10+ years since I used Delphi and even then only did it for about a year, so it is almost as if I am starting from scratch.