Sha256: 93abf7d48ed90b345ec42e33a043e9575b170e04894c9bb991f5a79db4003518

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'thor'

module S3sec
  # Handle the application command line parsing
  # and the dispatch to various command objects
  #
  # @api public
  class CLI < Thor
    # Error raised by this runner
    Error = Class.new(StandardError)

    desc 'version', 's3sec version'
    def version
      require_relative 'version'
      puts "v#{S3sec::VERSION}"
    end
    map %w(--version -v) => :version

    desc 'check', 'Check open buckets and public files'
    method_option :help, aliases: '-h', type: :boolean,
                         desc: 'Display usage information'
    def check(*)
      if options[:help]
        invoke :help, ['check']
      else
        require_relative 'commands/check'
        S3sec::Commands::Check.new(options).execute
      end
    end

    desc 'config', 'Configure aws credentials'
    method_option :help, aliases: '-h', type: :boolean,
                         desc: 'Display usage information'
    def config(*)
      if options[:help]
        invoke :help, ['config']
      else
        require_relative 'commands/config'
        S3sec::Commands::Config.new(options).execute
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
s3_sec-0.1.0 lib/s3sec/cli.rb