Sha256: 62650eb193aef8265c28d2250eb8cce10e40d2fc903f9db2796712b7fd9feab5

Contents?: true

Size: 1.7 KB

Versions: 15

Compression:

Stored size: 1.7 KB

Contents

require 'sct'
require "sct/config"
require 'sct/command'
require "sct/version"
require 'colored'
require 'commander'

module Sct
  class SctCore

    program :name, 'sct'
      program :version, Sct::VERSION
      program :summary, 'CLI helper tool for local SCT development'
      program :description, 'SCT is a CLI tool for developers using the Visma Continuous Deployment Model in conjunction with the Google Cloud Platform (GCP). It provides multiple command to set up and maintain a kubernetes cluster on a machine for local development'

    def self.take_off(cmds)
      self.new.run
      cmds.each { |cmd| registerCommand(cmd) }
    end

    def run 
      
    end

    def self.registerCommand(cmd)
      # validate Command Class
      if cmd.class != Class ||
        !cmd.name.end_with?('Command')
        return
      end
    
      # validate if Command is meant to be public
      if !cmd::IS_PUBLIC_COMMAND
        return
      end
    
      # register public Commands as CLI command
      command self.deduceCommandNameFromClass(cmd) do |c|
        c.syntax = cmd::SYNTAX
        c.summary = cmd::SUMMARY
        c.description = cmd::DESCRIPTION
        c.example cmd::EXAMPLE_DESCRIPTION, cmd::EXAMPLE
        cmd::OPTIONS.each { |option| c.option option.name, option.type, option.description }
        c.action do |args, options|
          cmd.new.execute(args, options)
        end
      end
    end

    # retrieves cli command-name from Command's full Class name
    def self.deduceCommandNameFromClass(c)
      name = c.name
      if name.include?('::')
        name = name.partition('::')[2]
      end
      # TODO replace camel-case capitals with '-'
      return name.chomp('Command').downcase
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
sct-0.1.18 lib/sct.rb
sct-0.1.17 lib/sct.rb
sct-0.1.16 lib/sct.rb
sct-0.1.15 lib/sct.rb
sct-0.1.14 lib/sct.rb
sct-0.1.13 lib/sct.rb
sct-0.1.12 lib/sct.rb
sct-0.1.11 lib/sct.rb
sct-0.1.10 lib/sct.rb
sct-0.1.9 lib/sct.rb
sct-0.1.8 lib/sct.rb
sct-0.1.7 lib/sct.rb
sct-0.1.6 lib/sct.rb
sct-0.1.5 lib/sct.rb
sct-0.1.4 lib/sct.rb