Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

AccuRev CLI Mode for Power CLI users

keith_berson Absent Member.
Absent Member.
0 0 1,327

I am new to this blog, so let me tell you a little about myself. I'm a principal engineer involved in the core development of the AccuRev product. I've been working for the company since March of 2015 and prior to that I worked at a company that used AccuRev for its SCM, so needless to say I am fast becoming a command-line power user. What this means is that there are some things I find I need to do when working with AccuRev that are faster to do from the command-line than going through the user interface.

For example, when we reached the end of the most recent development period, we entered into a phase that we refer to "end-game."  During this time, I spend cycles installing the release candidate on virtual machines, run sanity tests, then roll the VM back and repeat. Dropping to the command-line makes it easy to create the first user, quickly add a depot, stream and workspace, then move on to more tests. Doing this over and over (and over) led me to thinking I would like a tool that let me just type the AccuRev command I wanted to enter rather than repeatedly typing 'accurev' over and over again. (I know, not a big deal, but software engineers are notoriously lazy, it's why many of us got into writing software in the first place, especially tools). What I wanted was a tool that would help with this, and so the CLI mode was born.

The script is easy to install - for Windows, copy the batch file and the .py file to a folder that's on your PATH (on my Window machine, I've added a c:\MyBin folder where I put all my tools). You will also need to install Python 2.7.9 or better, if you haven't alreay. On Linux, copy the cli file instead and apply a 'chmod +x' to it (I've add a ~\MyBin to the PATH in my .bashrc file). If you take these steps, you should be able to just type 'cli' from the command line to enter into AccuRev CLI Mode.

The CLI Mode presents you with a simple prompt: ACC and you're ready to enter AccuRev commands.  The CLI also has some built in tools, and the list can be brought up by entering '?'  Currently, those commands are:

    "cd {directory}" - change to given directory
    "pwd" - show current working path
    "vers" - show which version of accurev is being used
    "quit" or "q" - quit CLI mode
    "rec" - start recording a script
    "stop" - stop recording a script
    "save" - save a script to a file
    "script {file}" - execute a script file
    "?" - this help"?" - this help

In addition, you can execute any native OS command by placing an "!" in front of it. For example, creating a folder within a workspace by entering '!mkdir subdir' allows me to then add it to the workspace with the 'add' command.

So far, I have found the ability to record the most powerful ability of the CLI mode. I can save the steps to a file using save, then play them back.  Scripts can even call other scripts, though recursion (script A calls script B which then calls script A) is blocked.

Lastly, this is a work in progress and I intend to add more features (some of my thoughts are some form of history, and the ability to display and change the AccuRev host server being accessed). The communication with accurev executable is simple and the script does not (currently) detect when AccuRev requires more from the user before continuing (for example, if you leave off required options, like comments on a keep).

The script can be found in the files section of the community board. Hope you find it as useful as I have.


The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.