Sha256: 395710d857d220032c301c98715fa74c0b0dfb6e639d72b38dc92c7937afafff

Contents?: true

Size: 536 Bytes

Versions: 2

Compression:

Stored size: 536 Bytes

Contents

require 'claide_completion/generator'

module CLAideCompletion
  def self.included(mod)
    if defined?(mod::DEFAULT_ROOT_OPTIONS)
      mod::DEFAULT_ROOT_OPTIONS << [
        '--completion-script', 'Print the auto-completion script'
      ]
    end
    mod.send(:prepend, Prepend)
  end

  module Prepend
    def handle_root_options(argv)
      return false unless self.class.root_command?
      if argv.flag?('completion-script')
        puts Generator.generate(self.class)
        return true
      end
      super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
claide-completion-1.0.2 lib/claide_completion.rb
claide-completion-1.0.1 lib/claide_completion.rb