Sha256: 6ee2d593a0b01e45642abb3ed5c97c141188be98216bbcb088238114cf408272

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

module PowerStencil
  module Utils

    module Completion

      include PowerStencil::Utils::DirectoryProcessor

      def generate_zsh_completion(script_name)

        # Dirty hack
        config.executable_gem_layer[:file_renaming_patterns] = {'(.+)_power_stencil.sh.erb' => '\1_power_stencil' }

        target_dir = File.expand_path config[:completion_target][:zsh][:completion_dir]
        source_dir = File.join PowerStencil::Project::Paths.system_templates_templates_path, 'zsh_command_line_completion'

        engine = PowerStencil::Engine::InitEngine.new
        engine.dsl = PowerStencil::Dsl::Completion
        engine.dsl.script_name = script_name
        engine.render_source source_dir, target_dir, overwrite_files: true

        puts_and_logs "zsh auto_completion has been installed in '#{File.join target_dir, "_#{script_name}"}'.", check_verbose: false
        puts "You should ensure you have something like 'fpath=(#{target_dir} $fpath)' in your ~/.zshrc file..."
        puts 'You may have to relog for changes to be applied.'
      end

    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
power_stencil-0.8.13 lib/power_stencil/utils/completion.rb
power_stencil-0.8.12 lib/power_stencil/utils/completion.rb
power_stencil-0.8.11 lib/power_stencil/utils/completion.rb
power_stencil-0.8.10 lib/power_stencil/utils/completion.rb
power_stencil-0.8.9 lib/power_stencil/utils/completion.rb
power_stencil-0.8.8 lib/power_stencil/utils/completion.rb
power_stencil-0.8.7 lib/power_stencil/utils/completion.rb
power_stencil-0.8.6 lib/power_stencil/utils/completion.rb
power_stencil-0.8.5 lib/power_stencil/utils/completion.rb
power_stencil-0.8.4 lib/power_stencil/utils/completion.rb
power_stencil-0.8.3 lib/power_stencil/utils/completion.rb
power_stencil-0.8.2 lib/power_stencil/utils/completion.rb
power_stencil-0.8.1 lib/power_stencil/utils/completion.rb
power_stencil-0.8.0 lib/power_stencil/utils/completion.rb