Sha256: 19c5ee21d7a830e434a9a5df4be0495a2d7e421b3c920ca3bbe2fd321499e35e

Contents?: true

Size: 529 Bytes

Versions: 1

Compression:

Stored size: 529 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.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

1 entries across 1 versions & 1 rubygems

Version Path
claide-completion-1.0.0 lib/claide_completion.rb