Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Error handling to the cmdline

  • Loading branch information...
commit 477847b9d1a1a12f5666758339cbe9ec3bfdb1f9 1 parent d0993f0
@HowardvanRooijen HowardvanRooijen authored
View
48 Solutions/Endjin.Templify.CommandLine/Client.cs
@@ -36,25 +36,33 @@ public Client()
public void Execute(string[] args)
{
- var options = this.CommandLineProcessor.Process(args);
-
- switch (options.Mode)
+ try
+ {
+ var options = this.CommandLineProcessor.Process(args);
+
+ switch (options.Mode)
+ {
+ case Mode.Create:
+ this.PackageCreatorTasks.CreatePackage(options);
+ break;
+ case Mode.Deploy:
+ this.PackageDeployerTasks.DeployPackage(options);
+ break;
+ case Mode.ShowTokens:
+ this.DisplayTokens(options);
+ break;
+ case Mode.ListPackages:
+ this.DisplayAvailablePackages(options);
+ break;
+ default:
+ Console.WriteLine(options.GetUsage());
+ break;
+ }
+ }
+ catch (Exception exception)
{
- case Mode.Create:
- this.PackageCreatorTasks.CreatePackage(options);
- break;
- case Mode.Deploy:
- this.PackageDeployerTasks.DeployPackage(options);
- break;
- case Mode.ShowTokens:
- this.DisplayTokens(options);
- break;
- case Mode.ListPackages:
- this.DisplayAvailablePackages(options);
- break;
- default:
- Console.WriteLine(options.GetUsage());
- break;
+ Console.WriteLine("Templify encountered an error: ");
+ Console.WriteLine(exception.Message);
}
}
@@ -74,8 +82,8 @@ private void DisplayAvailablePackages(CommandOptions options)
{
var packages = this.PackageDeployerTasks.RetrieveAllPackages(options.PackageRepositoryPath);
- Console.WriteLine(string.Format("Templify packages available in repository '{0}':",
- options.PackageRepositoryPath));
+ Console.WriteLine(string.Format("Templify packages available in repository '{0}':", options.PackageRepositoryPath));
+
foreach (var package in packages)
{
Console.WriteLine(" {0}", package.Manifest.Name);
View
3  Solutions/Endjin.Templify.Domain/Domain/Packager/Processors/CleanUpProcessor.cs
@@ -37,14 +37,13 @@ public void Process(string path)
private static void ForceDeleteDirectory(string path)
{
- DirectoryInfo currentFolder;
var folders = new Stack<DirectoryInfo>();
var root = new DirectoryInfo(path);
folders.Push(root);
while (folders.Count > 0)
{
- currentFolder = folders.Pop();
+ DirectoryInfo currentFolder = folders.Pop();
currentFolder.Attributes = currentFolder.Attributes & ~(FileAttributes.Archive | FileAttributes.ReadOnly | FileAttributes.Hidden);
foreach (var d in currentFolder.GetDirectories())
Please sign in to comment.
Something went wrong with that request. Please try again.