CLI Shaping Up
After the first two weeks of coding on the Mailman CLI, I can see the CLI shaping up,that too in a fast pace, in spite of my busy schedule these days. I have been able to adhere to the timeline suggested by me in my proposal.
The coding period began as a continuation of the community bonding period and I had to continue the process of discussing the design of the commands to be built, with the Mailman Community and my mentors. I received a lot of valuable feedback and comments from Steve, Barry, Abhilash and Patrick. I have already covered the core functionalities of the project and the CLI now supports the most of the common tasks like creation, listing and deletion of domains, users and mailing lists.
Abhilash suggested to follow TDD after my first revision this week. I had proposed to build unit tests in the last week of June, and when he suggested it, I decided to give it a try. I was overwhelmed by the power and essence of the approach, and also the enormity of the tasks I had procrastinated to the last week before mid term evaluation. I quickly went over a few pages about TDD and got a grasp on its usage.
I spent the weekend researching on the TDD and sat down to write the unittests for the `domain` scope. The next day, I submitted a revision(r56) with a huge diff of around 500 lines. I also happened to find a bug in my implementation during the testing. I stored the list of `scope` objects as an attribute to their respective classes. This attribute is static and won't be updated when a new instance gets added. This bug can limit the re usability of the classes being built. Anyhow, it was fixed by not storing the scope objects as an attribute.
Another major outcome of writing the tests is that I got a lot of room to refactor the code and make it better to read and reuse. The major change was to replace every instance of error message printing with an exception, and catching all those exceptions at a single point, and displaying the corresponding error message there. The error messages and confirmation messages are colored by using the escape sequence for each color.
Another new introduction was to move repetitive code to a common location, cli/lib, from where they are imported and used. The scope objects are now given constructors, receiving a client object as argument. The connection scripts have been moved to lib directory, and the connect method has been removed from each `scope`'s class. All errors are caught at the cmdparser.py and the received error messages are displayed in red.
The next set of tasks that I have to work during the following week include the `export` feature, describe object feature, unittests for scope `user`. In would be writing the tests for the new features first and then implementing them, as suggested by TDD. I also have to find some time to settle on a decent plan on how to approach the command shell. I have a bare bone picture on how to tackle it, but I will have to put it in writing and discuss it with the community before building it.