While coding I often have the need to create small sample-apps for debugging some library-code I'm writing or for figuring out what library code others have written does. Usually creating such a sample application not only involve creating and compiling some main.cpp as in a KDE context you also need some KAboutData, KComponentData as well as some basic CMakeLists.txt to actually be able to compile it.
While I could of course just construct some directories containing templates and just copy them to wherever I need it, I've lately been enjoying the power of KAppTemplate. This nifty little application uses pre-defined templates for various kinds of projects like KDE4 Applications, Qt4 Applications, Plasmoids and even PyKDE or KDERuby apps and a graphical assistant to get you going.
Now, I like doing stuff on the command-line and don't use all of the features KAppTemplate gives me (eg. filling the author or version part of the assistant is not needed of this particular use-case). So I decided to rip the template handling part of KAppTemplate to create my own little KAppTemplateCli to fit my needs.
Basic usage
Listing available templates
lemma@quechua:/tmp/tests$ kapptemplatecli --list
C++/KDE
kapp4 - KDE 4 GUI Application
plasmoid - Plasma Applet Template
runner - Plasma Runner Template
kpartapp - KDE 4 KPart Application
akonadiresource - Akonadi Resource Template
akonadiserializer - Akonadi Serializer Template
C++/No GUI (CMake)
cmake_plaincpp - Simple CMake-based C++ application
C++/Qt (cmake)
cmake_qt4core - Qt4 CMake Core application
cmake_qt4gui - Qt4 CMake Gui application
cmake_qt4core_qtest - Qt4 CMake QTest Core application
[... stripped ...]
Showing template information
lemma@quechua:/tmp/tests$ kapptemplatecli --info=kapp4
Category : C++/KDE
Basename : kapp4
Name : KDE 4 GUI Application
Description: KDE4 simple template based on CMake, inherits from XMLGuiWindow and demonstrates how to use KConfig XT
Creating an application from a template
lemma@quechua:/tmp/tests$ kapptemplatecli --template=kapp4 MyTest
lemma@quechua:/tmp/tests$ ls mytest
CMakeLists.txt doc icons README src
lemma@quechua:/tmp/tests$ mkdir mytest/build && cd mytest/build && cmake .. && make
lemma@quechua:/tmp/tests/mytest/build$ src/mytest
Download location & notes
Enjoy.