Giter Club home page Giter Club logo

plastic-cmdrunner's Introduction

plastic-cmdrunner

Utility to run Plastic SCM CLI "cm" commands from a different application (useful for plugins and scripts).

This project requires Visual Studio 2010 (or Visual Studio 2012) and .NET Framework 2 to compile.

The code consists of:

  • The CmdRunner (command runner) itself. This utility allows you to run cm commands from a .NET program, thus allowing writing connectors between Plastic SCM and other .NET-based applications. This application run cm commands in different process and parses the output obtained. You can run separate commands such as:

    cm find branches

    Or within a shell context, such as:

    cm shell

    find branches

    The main different between both uses is that the cm shell is faster when running several commands in a row, since the cm.exe application is already launched. In most cases this is the desired behaviour, since it is much better from the performance point of view. The counterpart of using this is that if some configuration happens (i.e.: the Plastic SCM server is changed in the client.conf), then the cm shell must be restarted to load the new changes.

  • CmdRunnerExample: This is an example of a very simple application that executes several common Plastic SCM commands and get the result in different ways: get the string result, get the command result (0 means success, other value means error). In order to test this example you need to have the "cm.exe" in your path and configured with a Plastic server that must be running.

  • sampleplasticapi: A sample API for PlasticSCM built using CmdRunner. Many of the basic operations (add, check-in, delete, etc.) are implemented. Also, a sample program to demonstrate the API usage is shipped along with the actual API code.

  • Samples: This project contains the source of all examples displayed in our CmdRunner Guide.

plastic-cmdrunner's People

Contributors

mig42 avatar ravelus avatar sergioluis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plastic-cmdrunner's Issues

ReadFileOutputWindows() loops forever

Hello im using function CmdRunner.ExecuteCommandWithStringResult("cm cat " + elem, Environment.CurrentDirectory) to get file from my repo. For some files i observed infinite loop, when my program hangs. During debugging i found that program constantly executes this line of code:

while (!TryToOpenFile(outputfile, ref sreader) && !proc.HasExited)
                {
                    result = RunWait(
                        proc, initWait,
                        ref lastElapsed,
                        ref totSeconds,
                        out error);

                    if (result != 0)
                        return result;
                }

in ReadFileOutputWindows() function in CodiceCmdRunner.cs

Further debugging showed me that line which causes this issue is this one:

if (line.StartsWith(COMMAND_RESULT))

when i observed last line of file i saw

}CommandResult 0

this bracket at beggining of line is last line of my file (just close bracket from some function from above). Due to this bracket at the beginning, bDone flag was never set to true and program went to infinite loop. So i swapped if (line.StartsWith(COMMAND_RESULT)) with if (line.Containd(COMMAND_RESULT)) and everything started to work correctly.

ProcessStartInfo ENVIRONMENT & UseShellExecute

Hi,

You may have an issue on InternalRun(string cmd, string workingdir, bool bRedirectStreams).
You plan to setup env variable for starting new process this way...
p.StartInfo.EnvironmentVariables[key] = mEnvironmentVariables[key] as string;
.. but since you setup p.StartInfo.UseShellExecute = false; to redirect stderr/stdin, the process will in fact take env variable from current one.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/7f668b1c-e982-4d5b-b229-0b0e0cf9c249/processstartinfo-environment-amp-useshellexecute?forum=netfxbcl

This fix let me transfer proper cm.exe location that is not in global PATH env. variable..

                foreach (string key in mEnvironmentVariables.Keys)
                {
                    //p.StartInfo.EnvironmentVariables[key] =
                    //    mEnvironmentVariables[key] as string;

                    Environment.SetEnvironmentVariable(key, mEnvironmentVariables[key] as string);
                }

Regads,
Charles

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.