require 'commander' require_relative 'runner' module Cluster class CommandsGenerator include Commander::Methods def self.start self.new.run end def run program :name, 'cluster' program :version, Sct::VERSION program :description, 'CLI for \'cluster\' - Manage your local kubernetes cluster' global_option('--verbose') { $verbose = true } command :up do |c| c.syntax = "sct cluster up" c.description = "Start the cluster" c.option '--clean', 'start a clean cluster. Old cluster will be purged if available.' c.action do |args, options| if options.clean Cluster::Runner.new.reset else Cluster::Runner.new.launch end end end command :down do |c| c.syntax = 'sct cluster down' c.description = 'stop the cluster' c.action do |args, options| Cluster::Runner.new.down end end command :reset do |c| c.syntax = 'sct cluster reset' c.description = 'reset your cluster and start with a clean cluster' c.action do |args, options| Cluster::Runner.new.reset end end alias_command :'setup', :'reset' command :status do |c| c.syntax = 'sct cluster status' c.description = 'see the status of your cluster' c.action do |args, options| Cluster::Runner.new.status end end command :'update config' do |c| c.syntax = 'sct cluster update config' c.description = 'update the cluster configuration' c.action do |args, options| Cluster::Runner.new.update_config end end command :'delete pods' do |c| c.syntax = 'sct cluster delete stalled pods' c.description = 'delete stalled pods from the cluster' c.option '--stalled', 'delete stalled pods' c.option '--all', 'delete all pods' c.action do |args, options| Cluster::Runner.new.delete_stalled_pods if options.stalled UI.important("Currently its not possible to delete all pods") if options.all end end default_command :status run! end end end