Skip to content

Commit

Permalink
Added copy option.
Browse files Browse the repository at this point in the history
Changed output folder naming convention (removed extension)
  • Loading branch information
renzfe committed Dec 27, 2016
1 parent 51047ee commit 620aa32
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 24 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# mbpm2git
* This utility converts .xep or .xel file into text file to be used with git or any other version control system
mbpm2git
===
mbpm2git is a command line tool that converts *.xep* or *.xel* file into text file to be used with git or any other version control system.

Overview
---
Metastorm BPM 7 procedures and libraries files are stored in zip format files with .xep or .xel extension.
This format is unsuitable to track changes or to be used with a version control system like git.
mbpm2git automates the workflow and extracts the content in text and xml files ready to be committed to git.

Install
---
- Copy the bin directory in *Programs Files* folder renaming it mbpm2git (`C:\Program Files\mbpm2git`)
- Add the folder to the system's path with **setx** command (`setx /m path "%path%;C:\Program Files\mbpm2git"`)

Use
---
**`mbpm2git.exe -i`***`xep/xel-file`***`-o`***`output-directory`***`[-f] [-c]`**

Options:
```
-i, --input Required. Input file to read
-o, --output Required. Output path to write
-f, --formatxml Format xml file
-c, --copy Copy xep or xel file
--help Display this help screen.
```

License
---
The license of the project is the [MIT](LICENSE).
3 changes: 2 additions & 1 deletion mbpm2git/Assets/DestinationFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public DestinationFolder(string d)
}
catch (Exception ex)
{
logger.Debug(ex.Message);
logger.Debug(ex.Message);
throw ex;
}
}

Expand Down
13 changes: 7 additions & 6 deletions mbpm2git/Assets/Procedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public bool IsLibrary()
{
bool lib = false;

if (_path.Extension.ToLower() == "xel".ToLower())
if (_path.Extension.ToLower() == ".xel".ToLower())
{
lib = true;
}
Expand All @@ -33,17 +33,18 @@ public string Name()
return _path.Name;
}

public string NameForDirectory()
{
string name4dir = Path.GetFileNameWithoutExtension(_path.Name);
return name4dir;
}

public Procedure(string path)
{
_path = new FileInfo(path);

if (_path == null) throw new Exception("invalid procedure path");

if (!_path.Exists)
{
_path = new FileInfo(Path.Combine(System.Reflection.Assembly.GetExecutingAssembly().Location, path));
}

if (!_path.Exists)
{
throw new Exception("procedure file does not exist");
Expand Down
24 changes: 15 additions & 9 deletions mbpm2git/Executer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,37 @@ public static void Execute(string[] args)
{
string procedureName = string.Empty;
string procedureDirecory = string.Empty;
bool formatExtractedXML = false;

var options = new Options();

if (CommandLine.Parser.Default.ParseArguments(args, options))
{
procedureName = options.InputFile;
procedureDirecory = options.OutputPath;

if (options.FormatExtractedXML)
{
formatExtractedXML = true;
}

logger.Debug("checking file {0}", procedureName);
logger.Debug("checking file: {0}", procedureName);
Procedure p = new Procedure(procedureName);
logger.Debug("procedure file: {0}", p.FullName());

logger.Debug("checking destination folder {0}", procedureDirecory);
logger.Debug("checking destination folder: {0}", procedureDirecory);
DestinationFolder d = new DestinationFolder(procedureDirecory);
logger.Debug("destination folder: {0}", d.FullName());

Extractor.Execute(p, d);
if (formatExtractedXML)

if (options.FormatExtractedXML)
{
logger.Debug("formatting xml files..");
FormatterForXML.XmlSearch(d.FullName());
}

if (options.CopyZippedFile)
{
string dest = Path.Combine(d.FullName(), p.Name());
logger.Debug("copy file {0}..", dest);
File.Copy(p.FullName(), dest, true);
}

logger.Info("Extraction done");
}
else
Expand Down
2 changes: 1 addition & 1 deletion mbpm2git/Operations/Extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void Execute(Procedure p, DestinationFolder d)

try
{
string subFolder = Path.Combine(d.FullName(), p.Name());
string subFolder = Path.Combine(d.FullName(), p.NameForDirectory());
finalDestination = new DirectoryInfo(subFolder);
logger.Debug("checking procedure folder {0}..", finalDestination.FullName);
if (finalDestination.Exists)
Expand Down
1 change: 1 addition & 0 deletions mbpm2git/Operations/FormatterForXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private static void FormatFile(string filePath)
}
catch(Exception ex)
{
logger.Error("Error {0}", ex.Message);
logger.Error("Error converting {0}", filePath);
}

Expand Down
10 changes: 6 additions & 4 deletions mbpm2git/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using CommandLine;
using CommandLine.Text;
using System.Reflection;

namespace mbpm2git
{
Expand All @@ -20,19 +21,20 @@ class Options
[Option('f', "formatxml", Required = false, HelpText = "Format xml file")]
public bool FormatExtractedXML { get; set; }

//[Option("length", DefaultValue = -1, HelpText = "The maximum number of bytes to process.")]
//public int MaximumLength { get; set; }
[Option('c', "copy", Required = false, HelpText = "Copy xep or xel file")]
public bool CopyZippedFile { get; set; }

[HelpOption]
public string GetUsage()
{
string v = Assembly.GetExecutingAssembly().GetName().Version.ToString(3);
var help = new HelpText
{
Heading = new HeadingInfo("mbpm2git.exe", "" ),
Heading = new HeadingInfo("mbpm2git.exe", v ),
AdditionalNewLineAfterOption = false,
AddDashesToOption = true
};
help.AddPreOptionsLine("Usage: mbpm2git.exe -i [xep file path] -o [output directory file path]");
help.AddPreOptionsLine("Usage: mbpm2git.exe -i xep_file_path -o output_directory_path [-f] [-c]");
help.AddOptions(this);

return help;
Expand Down
2 changes: 1 addition & 1 deletion mbpm2git/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.4.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit 620aa32

Please sign in to comment.