Skip to content

Commit

Permalink
Merge pull request #35 from faesel/list-filter
Browse files Browse the repository at this point in the history
added a contains filter for both queues and containers
  • Loading branch information
faesel committed Nov 7, 2020
2 parents 79d7e4d + d39b975 commit 29b4ef1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ To view a list of commands through the CLI you can use `azlazy --help`, each com
| Command | Description |
|--------------|:-------------|
| `azlazy addqueue --name "queue to add"` | Creates a new queue with the given name |
| `azlazy queue --list` | View a list of queues in the storage account along with the number of messages they are holding, poison queues are highlighted in red |
| `azlazy queue --list` | View a list of queues in the storage account along with the number of messages they are holding, poison queues are highlighted in red. You can also filter the list with `--contains` |
| `azlazy queue --remove "queue to remove"` | Removes the queue with the given name |
| `azlazy queue --cure "queue to move poison messages to"` | Moves poison queue messages back into the processing queue |
| `azlazy queue --clear "queue to clear"` | Removes all messages in the queue |
Expand All @@ -85,7 +85,7 @@ To view a list of commands through the CLI you can use `azlazy --help`, each com

| Command | Description |
|--------------|:-------------|
| `azlazy container --list` | View a list of containers in the storage account, along with whether or not its public and when it was last modified |
| `azlazy container --list` | View a list of containers in the storage account, along with whether or not its public and when it was last modified. You can also filter the list with `--contains` |

More coming soon !

Expand All @@ -111,3 +111,4 @@ I haven't written any contributing guidelines yet but you can reach me here on [
| 01/11/2020 | v1.1.0 | Added command to move messages from one queue to another |
| 04/11/2020 | v1.1.1 | Added a fix for printing out multiline JSON |
| 06/11/2020 | v1.1.2 | Added command to list containers |
| 06/11/2020 | v1.1.3 | Added a contains filter when listing queues and containers |
3 changes: 3 additions & 0 deletions az-lazy/Commands/Container/ContainerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ public class ContainerOptions : ICommandOptions
{
[Option('l', "list", Required = false, HelpText = "List all containers available")]
public bool List { get; set; }

[Option("contains", Required = false, HelpText = "Use in combination with list, allows you to filter the list returned")]
public string Contains { get; set; }
}
}
5 changes: 5 additions & 0 deletions az-lazy/Commands/Container/Executor/ListBlobExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public async Task Execute(ContainerOptions opts)
ConsoleHelper.WriteSepparator();
}

if(!string.IsNullOrEmpty(opts.Contains))
{
containers = containers.Where(x => x.Name.Contains(opts.Contains)).ToList();
}

foreach (var container in containers)
{
var isPublic = container.Properties.PublicAccess.HasValue ? "(public)" : "(private)";
Expand Down
6 changes: 6 additions & 0 deletions az-lazy/Commands/Queue/Executor/ListExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using az_lazy.Helpers;
using az_lazy.Manager;
Expand Down Expand Up @@ -34,6 +35,11 @@ public async Task Execute(QueueOptions opts)
ConsoleHelper.WriteLineSuccessWaiting(message);
ConsoleHelper.WriteSepparator();

if(!string.IsNullOrEmpty(opts.Contains))
{
queueList = queueList.Where(x => x.Name.Contains(opts.Contains)).ToList();
}

foreach (var queue in queueList)
{
await queue.FetchAttributesAsync().ConfigureAwait(false);
Expand Down
3 changes: 3 additions & 0 deletions az-lazy/Commands/Queue/QueueOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public class QueueOptions : ICommandOptions
[Option('l', "list", Required = false, HelpText = "List all connections available")]
public bool List { get; set; }

[Option("contains", Required = false, HelpText = "Use in combination with list, allows you to filter the list returned")]
public string Contains { get; set; }

[Option('r', "remove", Required = false, HelpText = "Queue name to remove")]
public string RemoveQueue { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion az-lazy/az-lazy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackAsTool>true</PackAsTool>
<ToolCommandName>azlazy</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<Version>1.1.2</Version>
<Version>1.1.3</Version>
<Id>azlazy</Id>
<Authors>Faesel Saeed</Authors>
<Owners>Faesel Saeed</Owners>
Expand Down
3 changes: 3 additions & 0 deletions documentation/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite?toc=/a

https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-containers-list?tabs=dotnet

Change table to CsConsoleFormat as it supports word wrap

https://stackoverflow.com/questions/856845/how-to-best-way-to-draw-table-in-console-app-c

0 comments on commit 29b4ef1

Please sign in to comment.