jsutterfield / pyclasstwitter

3 stars 5 forks source link

add command line argument parsing #2

Open eleddy opened 11 years ago

eleddy commented 11 years ago

Instead of main, allow the script to be run from the command line. This way you can pass the password in as an argument instead of checking it into a public repo.

jsutterfield commented 11 years ago

@abutton While I think this works well as a quick fix, it would probably be better implemented if we used the actual argparse library rather than just a raw_input prompt. We should also probably expand the arguments that the script can take to include to include the "to addresses" and the "from address" at least (especially because right now you'd be the only one with the password for the nbpyclasstest account), but potentially the "subject", "host" and "port" as well.

abutton commented 11 years ago

@jsutterfield yeah argparse looks like much better idea. I was just trying to close it quickly, should have implemented and left tag open for a better work around.

kellanjacobs commented 11 years ago

I thought it might be interesting to try to use http://docs.python.org/2/library/configparser.html to solve this issue. We could so like many other open source projects do and give a sample config and have the user make a copy and use that to put their settings in. We can also add the settings files to the .gitignore so that no one uploads it accidentally.

jsutterfield commented 11 years ago

@abutton Yea, we were under siege, fast measures had to be taken!

@kellanjacobs I like that idea. Especially if it's something that other open source projects do (since we're all learning how this stuff works anyway). How would that work: Would you have a basic config file, then have the user save it with a certain extension that the script looks for and is also in the .gitignore file? Otherwise we couldn't get it in the repo if the basic config is listed in .gitignore, right?

Also, what if we tried to do both and allowed the script to either read from a config file with a simple -f flag, or be passed in arguments from the command line. That wouldn't be too hard to implement, right?