lundi 18 avril 2016

Is there any design pattern or code sample for a command line tool supporting sub-command and parameters?

There are many command line tool such as 'git', 'brew', 'apt-get', etc. which support sub-command/action and parameters.

for exmaple: git is a command tool name, after inputting it you can add an action, and then the parameter as following,

git diff file_name
git branch -a
git checkout -b new_branch_name

for example: brew is a command line tool in OSX,

brew install component_name
brew search tool_name

Now, I want to implement a command line tool like these above. Is there any pattern to use? code sample will be highly appreciated.

Aucun commentaire:

Enregistrer un commentaire