Class: Pike13::CLI::Runner

Inherits:
Thor
  • Object
show all
Defined in:
lib/pike13/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/pike13/cli.rb', line 51

def self.exit_on_failure?
  true
end

.start(given_args = ARGV, config = {}) ⇒ Object

Hook to configure Pike13 before any command



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/pike13/cli.rb', line 56

def self.start(given_args = ARGV, config = {})
  # Skip config for help commands
  first_arg = given_args.first
  is_help_command = first_arg == "help" || first_arg == "version" ||
                    given_args.any? { |arg| arg.include?("--help") || arg.include?("-h") } ||
                    given_args.include?("help") # Catch help subcommand at any level
  unless is_help_command || given_args.empty?
    Config.configure_pike13!
  end
  super
rescue StandardError => e
  puts "Error: #{e.message}"
  exit 1
end

Instance Method Details

#versionObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/pike13/cli.rb', line 38

def version
  require "colorize" if $stdout.tty?

  puts "pike13-cli version #{Pike13::CLI::VERSION}".bold if $stdout.tty?
  puts "pike13-cli version #{Pike13::CLI::VERSION}" unless $stdout.tty?
  puts "pike13 gem version #{Pike13::VERSION}"
  puts "Ruby version: #{RUBY_VERSION}"
  puts ""
  puts "Environment:"
  puts "  PIKE13_ACCESS_TOKEN: #{ENV['PIKE13_ACCESS_TOKEN'] ? 'set' : 'not set'}"
  puts "  PIKE13_BASE_URL: #{ENV['PIKE13_BASE_URL'] || 'not set'}"
end