Sha256: 7acd4be80c6dd8fd36d49abc817e2b5203396e8735f38f9f3ea6453004a147d6
Contents?: true
Size: 1.59 KB
Versions: 4
Compression:
Stored size: 1.59 KB
Contents
module Kontena # Run a kontena command like it was launched from the command line. # # @example # Kontena.run("grid list --help") # # @param [String] command_line # @return [Fixnum] exit_code def self.run(cmdline = "", returning: :status) require 'shellwords' ENV["DEBUG"] && puts("Running Kontena.run(#{cmdline.inspect}, returning: #{returning}") result = Kontena::MainCommand.new(File.basename(__FILE__)).run(cmdline.shellsplit) ENV["DEBUG"] && puts("Command completed, result: #{result.inspect} status: 0") return 0 if returning == :status return result if returning == :result rescue SystemExit ENV["DEBUG"] && puts("Command completed with failure, result: #{result.inspect} status: #{$!.status}") returning == :status ? $!.status : nil end def self.version "kontena-cli/#{Kontena::Cli::VERSION}" end def self.pastel @pastel ||= Pastel.new(enabled: $stdout.tty?) end def self.prompt @prompt ||= TTY::Prompt.new( active_color: :cyan, help_color: :white, error_color: :red, interrupt: :exit, prefix: pastel.green('> ') ) end def self.root File.dirname(__dir__) end end # Monkeypatching string to mimick 'colorize' gem class String def colorize(color_sym) ::Kontena.pastel.send(color_sym, self) end end require 'ruby_dig' require_relative 'kontena/cli/version' require_relative 'kontena/cli/common' require_relative 'kontena/command' require_relative 'kontena/client' require_relative 'kontena/plugin_manager' require_relative 'kontena/main_command' require_relative 'kontena/cli/spinner'
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kontena-cli-0.16.0.pre5 | lib/kontena_cli.rb |
kontena-cli-0.16.0.pre4 | lib/kontena_cli.rb |
kontena-cli-0.16.0.pre3 | lib/kontena_cli.rb |
kontena-cli-0.16.0.pre2 | lib/kontena_cli.rb |