Sha256: 13a6bec5b4a7b4b0ba444f03c67cf3623da437afc55ad46285feb6e8e01fb919

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Emasser
  class CLI < Thor
    package_name 'Emasser'

    if ARGV[0].to_s.include? 'get'
      require 'emasser/get'
      register(Emasser::Get, 'get', 'get [RESOURCE]', 'Gets a resource')
    elsif ARGV[0].to_s.include? 'post'
      require 'emasser/post'
      register(Emasser::Post, 'post', 'post [RESOURCE]', 'Posts resources')
    elsif ARGV[0].to_s.include? 'put'
      require 'emasser/put'
      register(Emasser::Put, 'put', 'put [RESOURCE]', 'Puts resources')
    elsif ARGV[0].to_s.include? 'del'
      require 'emasser/delete'
      register(Emasser::Delete, 'delete', 'delete [RESOURCE]', 'Deletes resources')
    elsif (ARGV[0].to_s.include? '-v') || (ARGV[0].to_s.include? '-V')
      puts "emasser version: #{Emasser::VERSION}".green
      exit
    elsif ARGV[0].to_s.include? 'hello'
      user_name = ENV.fetch('USERNAME', 'rookie')
      puts "Hello #{user_name} - enjoy using emasser version #{Emasser::VERSION}!".cyan
      exit
    end

    def help
      puts 'Emasser commands:'.yellow
      puts '  emasser [get, put, post, delete, -v, or -V]'.yellow
    end

    def self.exit_on_failure?
      true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emasser-3.4.1 lib/emasser/cli.rb