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 Docker cluster' global_option('--verbose') { $verbose = true } 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 args, options end end 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 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 command :delete do |c| c.syntax = "sct cluster delete" c.description = "delete the cluster" c.action do |args, options| Cluster::Runner.new.delete end end 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.reset args, options end end 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 :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")' c.action do |args, options| Cluster::Runner.new.logs args, options end end run! end end end