module App

Constants

CONFIG_FILE
GEM_NAME
SCHEMA_FILE
SECRET
TEMPLATE_FILE

Public Class Methods

execute() click to toggle source
# File lib/eworld.rb, line 23
    def self.execute

        begin

            unless ARGV[0] == 'config' || ARGV[0] == 'x'
                Blufin::Config::init(SCHEMA_FILE, TEMPLATE_FILE, CONFIG_FILE, GEM_NAME)
                App::AWSProfile::init(Blufin::Config::get)
                Blufin::Projects.new(Blufin::Config::get['Projects'], App::AWSProfile::get)
            end

            Convoy::App.create do |app|

                app.version EWORLD_VERSION
                app.summary <<TEMPLATE
 \x1B[48;5;89m\x1B[38;5;255m eWorld-CLI \x1B[0m\x1B[0m \x1B[38;5;89m\xe2\x80\x94 eWorld Commmand-Line Interface\x1B[38;5;248m

        __        __         _     _            _ _
      __\\ \\      / /__  _ __| | __| |       ___| (_)
     / _ \\ \\ /\\ / / _ \\| '__| |/ _` |_____ / __| | |
    |  __/\\ V  V / (_) | |  | | (_| |_____| (__| | |
     \\___| \\_/\\_/ \\___/|_|  |_|\\__,_|      \\___|_|_|\x1B[0m
TEMPLATE
                app.description "\x1B[38;5;240mAn internal tool intended for improving/automating development tasks.\x1B[0m"

                # g - GENERATE
                if is_albert_mac
                    app.command :generate, :aliases => [:g] do |generate|
                        generate.summary 'Generate boiler-plate code'
                        generate.options do |opts|
                            opts.opt :silent, 'Run in silent mode', :short => '-s', :long => '--silent', :type => :boolean
                        end
                        generate.action do |opts, args|
                            AppCommand::Generate.new(opts, args).execute
                        end
                    end
                end

                # U - UPDATE
                app.command :update, :aliases => [:U] do |update|
                    update.summary 'Check for updates'
                    update.action do
                        Blufin::Update::run(App::GEM_NAME)
                    end
                end

                # v - VALIDATE
                if is_albert_mac
                    app.command :validate, :aliases => [:v] do |validate|
                        validate.summary 'Valdiate the codebase'
                        validate.options do |opts|
                            opts.opt :project, 'Specify Project ID', :short => '-p', :long => '--project', :type => :string
                        end
                        validate.action do |opts, args|
                            AppCommand::Validate.new(opts, args).execute
                        end
                    end
                end

                # x - CONFIG
                app.command :config, :aliases => [:x] do |config|
                    config.summary 'Setup your configuration file'
                    config.action do
                        Blufin::Config::edit_config(App::CONFIG_FILE)
                    end
                end

                # eworld - DEFAULT
                app.action do
                    system("#{App::GEM_NAME} -h")
                end

            end

        rescue RuntimeError => e

            Blufin::Terminal::print_exception(e);

        end

    end
is_albert_mac() click to toggle source

Very hacky code that looks in the configuration file for a key/pair value and if exists, returns true. @return bool

# File lib/eworld.rb, line 106
def self.is_albert_mac
    if Blufin::Config::get.has_key?('CustomOptions') && Blufin::Config::get['CustomOptions'].has_key?('Secret')
        return Blufin::Config::get['CustomOptions']['Secret'] == SECRET
    end
    false
end