From 19e6e14f01a6edb6dc1900544630542fb6e8809c Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 3 Jan 2014 10:40:13 +0100 Subject: [PATCH] cli: Add support for 'firing' projects. --- lib/kook/app.rb | 16 ++-------------- lib/kook/cli.rb | 5 ++++- lib/kook/project.rb | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/kook/app.rb b/lib/kook/app.rb index 7382060..ff3c835 100644 --- a/lib/kook/app.rb +++ b/lib/kook/app.rb @@ -59,20 +59,8 @@ module Kook raise MissingProject if not @projects.has_key? project_name project_path = @projects[project_name].path - @projects[project_name].each_view do |view,view_data| - target = ENV['KONSOLE_DBUS_SERVICE'] || 'org.kde.konsole' - session=`qdbus #{target} /Konsole newSession`.strip - - system "qdbus org.kde.konsole /Sessions/#{session} sendText \"cd #{project_path}\n\"" - system "qdbus org.kde.konsole /Sessions/#{session} sendText \"cd #{view_path}\n\"" - system "qdbus org.kde.konsole /Sessions/#{session} sendText \"clear\n\"" - system "qdbus org.kde.konsole /Sessions/#{session} setTitle 1 \"#{view}\"" - next unless config['commands'][project].has_key? view - config['commands'][project][view].each do |command| - system "qdbus org.kde.konsole /Sessions/#{session} sendText \"#{command}\"" - system "qdbus org.kde.konsole /Sessions/#{session} sendText \"\n\"" - end - end + @projects[project_name].fire + end def add_view project_name, view_name, view_path=nil diff --git a/lib/kook/cli.rb b/lib/kook/cli.rb index 4b9c4fe..87dbdea 100644 --- a/lib/kook/cli.rb +++ b/lib/kook/cli.rb @@ -162,8 +162,11 @@ module Kook subcommand "command", CLI::Command desc "fire [PROJECT]", "Run project environment" - def fire project_name=nil + + def fire before_filter options + project_name = @app.current_project + @app.fire_project project_name end diff --git a/lib/kook/project.rb b/lib/kook/project.rb index fe1de64..83a38c1 100644 --- a/lib/kook/project.rb +++ b/lib/kook/project.rb @@ -31,6 +31,23 @@ module Kook @path = path end + def fire + target = ENV['KONSOLE_DBUS_SERVICE'] || 'org.kde.konsole' + + @views.each do |view,view_data| + session=`qdbus #{target} /Konsole newSession`.strip + system "qdbus org.kde.konsole /Sessions/#{session} sendText \"cd #{@path}\n\"" + system "qdbus org.kde.konsole /Sessions/#{session} sendText \"cd #{view_data.path}\n\"" + system "qdbus org.kde.konsole /Sessions/#{session} sendText \"clear\n\"" + system "qdbus org.kde.konsole /Sessions/#{session} setTitle 1 \"#{view}\"" + + view_data.commands.each do |command| + system "qdbus org.kde.konsole /Sessions/#{session} sendText \"#{command}\"" + system "qdbus org.kde.konsole /Sessions/#{session} sendText \"\n\"" + end + end + end + def create_view view_name, view_path raise ExistingView, view_name if @views.has_key? view_name View.validate_name view_name