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 Berend (@asciimen).

    A repair-rebuild is quite simple to do with Curl. With S7 things became a bit more complex with OAuth, but we've done this and adapted our script for Sgr7 to do a similar thing: repair-rebuild, rebuild roles perhaps. It also handles the vardef-change SQL.

    But its hardly more usable than that.

    What would be really handy: a CLI studio; like add-field, rename field...

    Or at least a CLI vardef schema extractor & validator ;-)

Comment
  • Comment originally made by Berend (@asciimen).

    A repair-rebuild is quite simple to do with Curl. With S7 things became a bit more complex with OAuth, but we've done this and adapted our script for Sgr7 to do a similar thing: repair-rebuild, rebuild roles perhaps. It also handles the vardef-change SQL.

    But its hardly more usable than that.

    What would be really handy: a CLI studio; like add-field, rename field...

    Or at least a CLI vardef schema extractor & validator ;-)

Children
No Data