Sha256: 5b63a1b964c73c91dbc301915a7b48337d616c1f08d986726b9c9a6e1f0a861b
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
require 'sct' require 'sct/command' require "sct/version" require "sct/sct_folder" 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sct-0.1.2 | lib/sct.rb |
sct-0.1.1 | lib/sct.rb |