使用隐藏的窗口运行Tortoise SVN命令行命令 [英] Run Tortoise SVN command line commands with a hidden window

查看:550
本文介绍了使用隐藏的窗口运行Tortoise SVN命令行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装了命令行界面的Tortoise SVN。安装路径为 C:\Program Files\TortoiseSVN\bin 其中 svn.exe 使用任何SVN命令。



我开发了一个作为后台进程运行的Ruby Windows应用程序。此应用程序运行命令像

  svn info#{path_to_repository}

此命令调用 svn.exe ,如前所述。



问题是, svn.exe 闪烁一个命令提示符一秒并终止,因此如果我运行 svn info 十次为十个不同的存储库,然后屏幕闪烁十次,因为这个命令开发,以及时运行,屏幕闪烁十次定期。



我需要的是通过Tortoise SVN运行SVN命令,而不用 svn.exe 弹出屏幕和关闭。

解决方案




I have Tortoise SVN with a command-line interface installed. The installation path is C:\Program Files\TortoiseSVN\bin where svn.exe is used whenever I use any SVN command.

I developed a Ruby Windows application which is run as a background process. This application runs the command like

svn info "#{path_to_repository}"

This command invokes svn.exe as I mentioned.

The problem is, svn.exe flashes a command prompt for a second and terminates, thus if I run svn info ten times for ten different repositories then the screen flickers ten times as this command is developed to run in a timely fashion, the screen flickers ten times regularly.

What I need is a way to run SVN commands through Tortoise SVN without the svn.exe popping up the screen and closing.

解决方案

Ruby has numerous way of executing command in shell, however, with all the options a command line popup seem to appear when using in GUI App.

Depending on what details you are looking for in svn info, one option you can use something like WebSVN and see if you can want to scrape the GUI or get data from its RSS feed. Take a look at demo site of this product.

If you have very specific and minimal needs, then, you can also choose to build a small REST API which can query the subversion server using command line. You can in that case call that REST API to fetch the data and avoid popping up of command windows.

If you are really short on time or do not have server infrastructure to host REST API, then, you can think of creating a Ruby App that runs a socket server and can run the shell command on receiving commands from client. Then, you can make your GUI App connect to the socket server using socket client and ask the server app to execute svn info and return result. Go through the tutorial on building such interacting apps. You can then choose to run them side-by-side on same PC.

Another alternative is to use Ruby SVN bindings. It may require some digging around to get this to work.

Here is quick starter code:

server.rb - a ruby TCP server that accepts commands and executes them in shell

require 'socket'

server = TCPServer.open(2000)   # Socket to listen on port 2000
puts "Listening now #{server.addr}"
loop {
  Thread.start(server.accept) do |client|
    cmd = client.gets

    puts "Processing #{cmd} from #{client.peeraddr}"

    IO.popen(cmd) { |s| result = []; 
        while (line = s.gets) do 
            client.puts line.chop 
        end; 
    }

    client.close
  end
}

app.rb A Shoes GUI app that issues svn info command to TCP server being run by server.rb

require 'socket'

Shoes.app {

    stack do 
        @push = button "Get SVN Info"
        @note = para ""
    end

    @push.click {

        hostname = 'localhost'
        port = 2000

        result  = []
        s = TCPSocket.open(hostname, port)
        s.puts "svn info trunk/backend"

        while line = s.gets 
          result << line.chop
        end
        s.close

        @note.replace result.join("\n")
    }
}

app.rb should be launched using shoes app.rb command.

这篇关于使用隐藏的窗口运行Tortoise SVN命令行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆