Sha256: b13691c1836d175eeb0ff81bc4b7a48e9c70af317c037613f4678f041e787454

Contents?: true

Size: 980 Bytes

Versions: 6

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

require 'tty-progressbar'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'completion'))
require 'string'
require 'fish_completion'
require 'zsh_completion'
require 'bash_completion'

module Doing
  # Completion script generator
  module Completion
    class << self
      def generate_completion(type: 'zsh', file: 'stdout')

        generator = case type.to_s
                    when /^f/
                      FishCompletions.new
                    when /^b/
                      BashCompletions.new
                    else
                      ZshCompletions.new
                    end

        result = generator.generate_completions

        if file =~ /^stdout$/i
          $stdout.puts result
        else
          File.open(File.expand_path(file), 'w') do |f|
            f.puts result
          end
          Doing.logger.warn('File written:', "#{type} completions written to #{file}")
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
doing-2.0.25 lib/doing/completion.rb
doing-2.0.24 lib/doing/completion.rb
doing-2.0.23 lib/doing/completion.rb
doing-2.0.22 lib/doing/completion.rb
doing-2.0.21 lib/doing/completion.rb
doing-2.0.20 lib/doing/completion.rb