Utility classes for command line applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Malte Bublitz 9d87c17bc7 Added dist/ to .gitignore 5 years ago
CLIApp CLIApp.__init__ now imports simple_app, too 7 years ago
.gitignore Added dist/ to .gitignore 5 years ago
COPYING.md Added my website URL in COPYRIGHT.md 7 years ago
README.md Optical FIX in the example II 7 years ago
setup.py New minor release 7 years ago
test.sh Merge branch 'master' of github.com:malte70/pyCLIApp 7 years ago

README.md

pyCLIApp

pyCLIApp is a basic bootstrap framework for command line applications written in Python, mainly on GNU/Linux and other Unix–Systems.

Installation

Before installing, especially if you cloned the Git master branch, you should run test.sh to ensure everything works before installing. After that, you can run setup.py to install:

./test.sh && python setup.py install

Example

from CLIApp.simple_app import SimpleCLIApp

APP_NAME       = "Hello World Example"
APP_VERSION    = "0.1"
APP_EXECUTABLE = "example"

class HelloWorldApp(SimpleCLIApp):
	def _version(self):
		self.c.writeln(APP_NAME + " " + APP_VERSION)
		
	def _help(self):
		self.c.writeln("Usage: {} <name>".format(APP_EXECUTABLE))
		
	def _greet(self, name):
		self.c.writeln("Hello, {}!".format(name))
		
	def run(self):
		if "-h" in self._options:
			self._help()
		elif "-V" in self._options or "-v" in self._options:
			self._version()
		else:
			if len(self._arguments) > 0:
				name = " ".join(self._arguments)
			else:
				name = "World"
			self._greet(name)
		
def main():
	app = HelloWorldApp()
	app.run()

if __name__=="__main__":
	main()