Let’s make a command line Sugar utility tool

Post originally written by Jesse.

When you work with something everyday, eliminating tedious and repetitive tasks not only improves your productivity but also helps your sanity. With Sugar, there are certain things we as developers are constantly doing; in some cases, over and over again. How many times have you run quick repair and rebuild?

Luckily, we program things. We write scripts that make our lives in that moment a tad bit easier. But it's easy to lose track of these things; we might even write the same tool over and over again.

In this series of posts, we're going to build a command line utility tool whose only purpose is to make life more beautiful. If you've ever used the laravel framework, you are familiar with the "artisan" tool which is built with the symfony console component. We are going to do the same thing.

The general idea here is to be able to call commands like these:

$ sugarcli admin:repair

$ sugarcli manifest:validate

Let's get started.

We are going to be using symfony console composer, so if you aren't familiar be sure to read-up on it. The first thing, we need to do is pull in our symfony console dependency in composer.json.

{

    "require": {

        "symfony/console": "v2.4.4"

    },

    "autoload": {

        "psr-4": {

            "Fbsg\\": "src"

        }

    }

}

$ composer install

Notice that we are using psr-4 for are auto-loading our classes, as we will be using psr compliant namespaces.

Now that we have our dependencies installed to the vendor folder, we are ready to start.

In the next post, we'll be building the quick repair/rebuild command.

You can view the github repository here.

Post From Faye Business Systems Group Director of Development Matthew Strickland

Contact Jesse Heller

Parents
  • Comment originally made by Joe.

    Hello,

    Once experienced Sugar dev/admin swinging by to check things out and hoping to maybe convince my current company how Sugar can make things better.

    Anyway, saw this thread and wanted to chime in that I think this is a FANTASTIC idea, and it's something I'd mentioned (somewhere... Twitter?) in the past. I'm a Drupal guy (Sugar's website is built with Drupal :) and Drush is a phenomenally useful tool. Quickly and easily run arbitrary scripts in a bootstrapped Drupal install, clear caches (drush cc all;) , download and install contrib, backup, stage, deploy, run updates and so much more. What a great project.

    Just a long-winded way of saying 'Let's do this!'

Comment
  • Comment originally made by Joe.

    Hello,

    Once experienced Sugar dev/admin swinging by to check things out and hoping to maybe convince my current company how Sugar can make things better.

    Anyway, saw this thread and wanted to chime in that I think this is a FANTASTIC idea, and it's something I'd mentioned (somewhere... Twitter?) in the past. I'm a Drupal guy (Sugar's website is built with Drupal :) and Drush is a phenomenally useful tool. Quickly and easily run arbitrary scripts in a bootstrapped Drupal install, clear caches (drush cc all;) , download and install contrib, backup, stage, deploy, run updates and so much more. What a great project.

    Just a long-winded way of saying 'Let's do this!'

Children
No Data