Wp-cli - A command line tool to do work on a Wordpress from the command line. 15 years ago
Or you could save yourself some time and use/contribute to wpshell: http://code.trac.wordpress.org/browser/wpshell
It's helpful to look for prior art before starting a project. ;)