python-dirbtuves / internet-voting

Internet voting system.
1 stars 2 forks source link

Command line voting client argument parser #5

Open sirex opened 9 years ago

sirex commented 9 years ago

First, you need to create setup.py file for internet voting library. This repository will be used for library purposes, together with basic command line client. So thing about this repository more like a library rather than command line client.

For command line script use console scripts entry point.

Use Python 3.

For command line script arguments use argparse.

Basically what you need to do is this:

$ voter <id> <subcommand>[ <arguments>]

For example:

$ voter 1 register
{'id': '1', 'command': 'register', 'args': []}

$ voter 1 verify voters
{'id': '1', 'command': 'verify voters', 'args': []}

$ voter 1 vote
{'id': '1', 'command': 'vote', 'args': []}

$ voter 1 verify my vote
{'id': '1', 'command': 'verify my vote', 'args': []}

$ voter 1 verify all votes
{'id': '1', 'command': 'verify all votes', 'args': []}

$ voter 1 count votes
{'id': '1', 'command': 'count votes', 'args': []}

As you see, subcommand can have more than one word, also there should be fixed list of known commands if an unknown command will be entered, show error message.

I would suggest to pop arguments and take voter id and subcommand and then pass arguments of subcommand to be process using argparse.

sirex commented 9 years ago

So, as we discussed, the command line interface changed a bit.

I think, it could like something like this:

$ voter register <registration_id>

$ voter pull

$ voter start-node[ <host>[:<port>]]

$ voter vote

$ voter sign

$ voter count

To implement this you can use argparse sub-commands.

Let me know if you have any questions.