mwrlabs/mercury — pull request #23 by luander (2012-06-26 22:37:20+00:00)
Title: Redirect output stream to a file.

Hi Tyrone,
I've made some changes in the client to accept an argument that redirect the output of a command to a file.
I've added a new class inside 'basecmd' called 'BaseArgumentParser' that adds support for '--output' argument to any command that uses it.

In order to a command to support redirection of the output, the only change you have to do is:
instead of:
parser = argparse.ArgumentParser(prog = 'start', add_help = False)
use this:
parser = BaseArgumentParser(prog = 'start', add_help = False)
*Don't forget to import BaseArgumentParser from basecmd

By doing this, you automatically add support to the argument that redirects the output to a file.

To redirect the output of a command to a file you must add the following arguments:

--output (or -o)

We designed this to add output support for all commands without taking much changes in the actual structure.
If there is another argument that should be common to all commands, it can be added in the '__init__' method of 'BaseArgumentParser'.

I hope this new feature is useful to Mercury.
[]'s
Luander