Build your application quickly with Quickly: Inside Quickly part 2

This session is giving some fundamentals on Quickly, let's dive into them!

Two components: core and template

There is mainly two parts in Quickly: Quickly Core is a command line parser and context checker. It has builtin commands and can handle and launch template commands. Quickly templates are group of commands and files that are used on a certain purpose: you can create templates to manage your documents, a LaTeX skeleton, or to easily create projects gathering a certain number of technologies.

Consequently, using templates, you can create a project which will be binded to your templates. Templates can be written in whatever language you wish. That's the reason why we don't use optparse in Quickly Core component.

The application can be extended to run on other systems, and use different tools, etc... There is nothing stopping you from doing that. However, if you stray off the chosen path, some of the commands may no longer work for you.

We would love to see, for instance, a fedora-project template, gnome-project one, plasmoid-project, zeitgeist-plugin... and this tour will give you some trick to help you create one (in part 6).

But again, consider that you can create your template for everything, like managing your documents (without even creating any project). You can give some commands to create a new "company's set of documents" for a secretary ; he/she will complete them and then "quickly share" (for instance) for uploading it in the company's sharing documentation server. Quickly Core is not binding into developing only, power is completely given to template developers.

The ubuntu-project templates

The ubuntu-project template is the first template released today (some more coming for creating gedit plugins and ubuntu-game template).

The ubuntu-project template enables you to easily create a project using a given set of strong opinionated chosen technology ubuntu's people are mostly using:

  • Python for the language
  • pygtk for the UI framework
  • Glade for the UI editor
  • Gedit for the code editor
  • bzr for version control
  • Launchpad for code hosting
  • desktopcouch for storage/database

The idea is to make choices (as Ubuntu make choices in their default applications list) for developers wondering what technology is "good to use for...". Choosing in a technology jungle can sometimes be a mess. Nevertheless, this is just a the skeleton: nothing prevents you for removing the desktopcouch part if you don't want to use it for instance (same for other pieces of technology).

It's also easy to create your own template from ubuntu-project to remove what part you don't want (if you are found of git and don't want to use bzr, for example). More on that in next sections.

Also note, there is no Quickly runtime or base class library. Using the Ubuntu Project won't bring in any dependency on Quickly itself.

Templates, context and command management.

General

So, we have builtin and template command and you can also be inside or outside a project. All that forms a context.

A project created with the create command will be associated with the template used in the create command like in:
$ quickly create ubuntu-project foo[1]
This command can only be launched outside any Quickly project and needs a template to be specified on the command line.

Then, when you are in a project, you can launch $ quickly <command> to launch the <command> from the binded templates or Quickly builtin command. No need to specify a template.

Also, you can launch any command wherever you wish in the project hierarchy (subfolder, subsubfolder...), the command will behave the way it's designed.

Get the list of all available commands.

Nothing more easy, just run wherever you wish:

$ quickly commands
[builtins]      commands
[builtins]      getstarted
[builtins]      help
[builtins]      quickly
[ubuntu-project]        change-lp-project
[ubuntu-project]        create
[ubuntu-project]        dialog
[ubuntu-project]        edit
[ubuntu-project]        glade
[ubuntu-project]        license
[ubuntu-project]        package
[ubuntu-project]        release
[ubuntu-project]        run
[ubuntu-project]        save
[ubuntu-project]        share
[ubuntu-project]        tutorial

builtins are... builtins command and others are templates owning commands. You can even check there that commands is a builtin one.

Choosing the template

You can still launch commands from another template in your current project. Let's say you need the "awesome" command from the bar template to be launched in your current ubuntu-project "templated" project, you still can with $ quickly --template bar awesome[2]

Attributes of commands/Advanced brain breaker :)

WARNING: this part can be seen as quite tricky. It's needed if you really want to understand the template and builtin commands behavior or want to create your own template. If you don't understand/want to read it, don't desesperate and just jump into the "Ok, you killed me, what do I really need to know?" section :)

Command attributes

As already said, some commands (templates and builtin ones) can either:

  • be launched outside a project only (case of "create" from ubuntu-project template command, for instance)
  • be launched inside a project only (case of "release" from ubuntu-project template command, for instance)
  • be launched outside or inside a project (case of "tutorial" from ubuntu-project template command, "commands" builtin command, for instance)

The check is done during command launch (and shell-completion filtering as well) to ensure user doesn't perform any mistake (as users make some mistakes sometimes, don't they? ;)). For instance, if you try to launch a command which can only be launched inside a project: didrocks@laptop:~/not_a_quickly_project$ quickly --template ubuntu-project release
ERROR: Can't find project in /home/didrocks/not_a_quickly_project.
Ensure you launch this command from a quickly project directory.
Aborting

Template command launched outside a project must be followed by a template if not specified as an option. Of course, this enables Quickly Core to know in which template to find the command. This will give:

$ quickly create ubuntu-project foo
                 ^^^^^^^^^^^^^^ ^^^
                     template  command arg

or:

$ quickly -t ubuntu-project create foo
          ^^^^^^^^^^^^^^^^^        ^^^
          template as an option  command arg

Same for tutorial command, which is an ubuntu-project command:

$ quickly tutorial ubuntu-project
                   ^^^^^^^^^^^^^^
                   template following command

or:

$ quickly -t ubuntu-project tutorial
          ^^^^^^^^^^^^^^^^^
         template as an option

Note: -t templatename can be set wherever on the command line.

As we will see in a later part, shell-completion automatically propose template commands that can be launched outside a project if you are outside a project, or inside if you are ... in a project folder. :)

As builtin commands are generalists, most of them doesn't need any template. But some have the attribute "followed by template" which will need also a template (example: 'help', 'quickly') specified on the command line.

An additional attribute we will se later is "followed by command" (case of the help command). There will be a dedicated part of the help.

Launch a template command outside a project

In case you launch a template command which is part of a template without specifying the template (either with -t option or following the command), you will have a message like that:
$ quickly tutorial
ERROR: tutorial command must be followed by a template and no template was found on the command line.
Candidates template are: footemplate, ubuntu-project
Arborting.

That means that both footemplate and ubuntu-project templates have a tutorial command and Quickly in all its kindness found them to help you. :)

So, then, you can try to launch (if quickly tutorial doesn't take any additional argument, which is the case): $ quickly tutorial footemplate or $ quickly tutorial ubuntu-project.

Ok, you killed me, what do I really need to know?

Phew, this was the harder part of Quickly's concept. Now, the following will seem to be really easy once you get this. In any case, shell-completion will only propose in the current context what you need/can launch (we will discuss that later). So, if you are lost, just let you guided by it, it will propose whenever template/command args you need to specified in the current context. :)

Only knowing what is a template and a project should be sufficient for a daily (and happy? ;)) Quickly user.

Next part will be on getting help on commands.

Notes

[1] foo can be also path/to/foo if path/to exists

[2] -t instead of –template if you are lazy :)

Share Comments
comments powered by Disqus