Skip to content

Console scenario

Created by: sagikazarmark

I am currently working on a console application and it works like the following:

  • The application loads some default option into the Getopt class.
  • Runs parse and checks if help or version option is passed.
  • If not, it looks for the desired command based on the first operand (if any).
  • Then the command adds it's own option definitions
  • The command gets run

My problem is that if a command defines some options then it simply fails because when parse is called they are not defined yet. I saw some PRs/issues for explicit options. Will it solve it solve my problem?

Also, I am curious if there are any way to remove operands (the command name) from the object. It seems that $operand is private so I hardly see a solution by extending the class.