cluster/lib/cluster/commands_generator.rb in sct-0.1.35 vs cluster/lib/cluster/commands_generator.rb in sct-1.0.0

- old
+ new

@@ -1,97 +1,102 @@ require 'commander' require_relative 'runner' module Cluster - class CommandsGenerator - include Commander::Methods + class CommandsGenerator + include Commander::Methods - def self.start - self.new.run - end + 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' + def run + program :name, 'cluster' + program :version, Sct::VERSION + program :description, 'CLI for \'cluster\' - Manage your local Docker cluster' - global_option('--verbose') { $verbose = true } + global_option('--verbose') { $verbose = true } - command :start do |c| - c.syntax = "sct cluster start" - c.description = "start the cluster" + command :start do |c| + c.syntax = "sct cluster start" + c.description = "start the cluster" + c.option '--build', '(re)build images before starting' + c.option '--pull', 'pull latest images before starting' - c.action do |args, options| - Cluster::Runner.new.start - end + c.action do |args, options| + Cluster::Runner.new.start args, options + end + end - end + command :stop do |c| + c.syntax = 'sct cluster stop' + c.description = 'stop the cluster' - command :stop do |c| - c.syntax = 'sct cluster stop' - c.description = 'stop the cluster' + c.action do |args, options| + Cluster::Runner.new.stop + end + end - c.action do |args, options| - Cluster::Runner.new.stop - end - end + command :restart do |c| + c.syntax = "sct cluster restart" + c.description = "restart the cluster" - command :restart do |c| - c.syntax = "sct cluster restart" - c.description = "restart the cluster" + c.action do |args, options| + Cluster::Runner.new.restart + end + end - c.action do |args, options| - Cluster::Runner.new.restart - end + command :delete do |c| + c.syntax = "sct cluster delete" + c.description = "delete the cluster" - end + c.action do |args, options| + Cluster::Runner.new.delete + end + end - command :delete do |c| - c.syntax = "sct cluster delete" - c.description = "delete the cluster" + command :reset do |c| + c.syntax = 'sct cluster reset' + c.description = 'delete the cluster and start a new cluster' - c.action do |args, options| - Cluster::Runner.new.delete - end + c.action do |args, options| + Cluster::Runner.new.reset args, options + end + end - end + command :pull do |c| + c.syntax = 'sct cluster pull' + c.description = 'pull new image versions' - command :reset do |c| - c.syntax = 'sct cluster reset' - c.description = 'delete the cluster and start a new cluster' + c.action do |args, options| + Cluster::Runner.new.pull + end + end - c.action do |args, options| - Cluster::Runner.new.reset - end - end + command :status do |c| + c.syntax = 'sct cluster status' + c.description = 'see the status of your cluster' - 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 - c.action do |args, options| - Cluster::Runner.new.status - end - end + command :logs do |c| + c.syntax = 'sct cluster logs' + c.description = 'see the logs of your cluster' + c.option '-f', 'follow log output' + c.option '--follow', 'follow log output' + c.option '-t', 'show timestamps' + c.option '--timestamps', 'show timestamps' + c.option '--tail LINES', 'number of lines to show from the end of the logs for each container (default: "all")' - 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 :'apply deployments' do |c| - c.syntax = 'sct cluster apply deployments' - c.description = 'apply deployments from the k8s folder' - - c.action do |args, options| - Cluster::Runner.new.apply_deployments - end - end - - run! + c.action do |args, options| + Cluster::Runner.new.logs args, options end + end + + run! end + + end end