lib/jkr/cli.rb in jkr-0.2.1 vs lib/jkr/cli.rb in jkr-0.2.2

- old
+ new

@@ -138,9 +138,34 @@ puts "#{File.basename(File.dirname(m))} | #{disp}" end end + desc "init-shell", "Generate shell script to init shell completion" + option :bash, :type => :boolean, :default => false + option :zsh, :type => :boolean, :default => false + def init_shell() + gem_dir = File.expand_path("../../", __dir__) + + if options[:bash] + puts <<EOS +# bash completion support is not implemented yet. +EOS + elsif options[:zsh] + puts <<EOS +# Add a following line to ~/.zshrc +# +# eval "$(jkr init-shell --zsh)" + +source #{File.expand_path("etc/zsh-comp.sh", gem_dir)} +compdef _jkr jkr +EOS + else + puts(red("[ERROR] Specify a shell type")) + exit(false) + end + end + no_commands do def find_plan_file(plan_name) @jkr_env.plans.find do |plan_file_path| File.basename(plan_file_path) == plan_name + ".plan" end