Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove cmdlet use verbose stream

  • Loading branch information...
commit 8abfb75233ed5444cdd3ac402210db2b02a48238 1 parent f464a0d
@xmbms xmbms authored
View
2  WindowsAzurePowershell/src/Management.Storage.Test/Blob/Cmdlet/RemoveAzureStorageBlobTest.cs
@@ -219,7 +219,7 @@ public void ExecuteCommandRemoveBlobTest()
command.Container = containerName;
command.Blob = blobName;
command.ExecuteCmdlet();
- string result = (string)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
+ string result = (string)((MockCommandRuntime)command.CommandRuntime).VerboseStream.FirstOrDefault();
Assert.AreEqual(String.Format(Resources.RemoveBlobSuccessfully, blobName, containerName), result);
AssertThrows<ResourceNotFoundException>(() => command.ExecuteCmdlet(),
String.Format(Resources.BlobNotFound, blobName, containerName));
View
6 WindowsAzurePowershell/src/Management.Storage.Test/Blob/Cmdlet/RemoveAzureStorageContainerTest.cs
@@ -72,7 +72,7 @@ public void RemoveContainerCancelledTest()
string name = "test";
((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
command.RemoveAzureContainer(name);
- string result = (string)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
+ string result = (string)((MockCommandRuntime)command.CommandRuntime).VerboseStream.FirstOrDefault();
Assert.AreEqual(String.Format(Resources.RemoveContainerCancelled, name), result);
}
@@ -86,7 +86,7 @@ public void RemoveContainerSuccessfullyTest()
((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
command.confirm = true;
command.RemoveAzureContainer(name);
- string result = (string)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
+ string result = (string)((MockCommandRuntime)command.CommandRuntime).VerboseStream.FirstOrDefault();
Assert.AreEqual(String.Format(Resources.RemoveContainerSuccessfully, name), result);
((MockCommandRuntime)command.CommandRuntime).ResetPipelines();
@@ -94,7 +94,7 @@ public void RemoveContainerSuccessfullyTest()
command.Force = true;
command.confirm = false;
command.RemoveAzureContainer(name);
- result = (string)((MockCommandRuntime)command.CommandRuntime).OutputPipeline.FirstOrDefault();
+ result = (string)((MockCommandRuntime)command.CommandRuntime).VerboseStream.FirstOrDefault();
Assert.AreEqual(String.Format(Resources.RemoveContainerSuccessfully, name), result);
}
View
10 WindowsAzurePowershell/src/Management.Storage/Blob/Cmdlet/RemoveAzureStorageBlob.cs
@@ -86,6 +86,9 @@ public SwitchParameter Force
}
private bool force = false;
+ [Parameter(Mandatory = false, HelpMessage = "Return whether the specifed blob is successfully removed")]
+ public SwitchParameter PassThru { get; set; }
+
/// <summary>
/// Initializes a new instance of the RemoveStorageAzureBlobCommand class.
/// </summary>
@@ -285,7 +288,12 @@ public override void ExecuteCmdlet()
result = String.Format(Resources.RemoveBlobCancelled, blobName, containerName);
}
- WriteObject(result);
+ WriteVerbose(result);
+
+ if (PassThru)
+ {
+ WriteObject(removed);
+ }
}
}
}
View
12 WindowsAzurePowershell/src/Management.Storage/Blob/Cmdlet/RemoveAzureStorageContainer.cs
@@ -48,6 +48,9 @@ public SwitchParameter Force
}
private bool force;
+ [Parameter(Mandatory = false, HelpMessage = "Return whether the specifed blob is successfully removed")]
+ public SwitchParameter PassThru { get; set; }
+
/// <summary>
/// Initializes a new instance of the RemoveAzureStorageContainerCommand class.
/// </summary>
@@ -99,18 +102,25 @@ internal void RemoveAzureContainer(string name)
}
string result = string.Empty;
+ bool removed = false;
if (force || ConfirmRemove(name))
{
Channel.DeleteContainer(container, accessCondition, requestOptions, OperationContext);
result = String.Format(Resources.RemoveContainerSuccessfully, name);
+ removed = true;
}
else
{
result = String.Format(Resources.RemoveContainerCancelled, name);
}
- WriteObject(result);
+ WriteVerbose(result);
+
+ if (PassThru)
+ {
+ WriteObject(removed);
+ }
}
/// <summary>
Please sign in to comment.
Something went wrong with that request. Please try again.