mirror of
https://github.com/oliverbooth/fdup.git
synced 2024-12-05 02:08:48 +00:00
refactor: move stack push to method
reduces method complexity and now Rider isn't crying
This commit is contained in:
parent
435318cd20
commit
3396c2bc74
@ -89,18 +89,7 @@ internal sealed class ListCommand : AsyncCommand<ListSettings>
|
|||||||
if (relativePath != ".")
|
if (relativePath != ".")
|
||||||
AnsiConsole.MarkupLineInterpolated($"Searching [cyan]{relativePath}[/]");
|
AnsiConsole.MarkupLineInterpolated($"Searching [cyan]{relativePath}[/]");
|
||||||
|
|
||||||
if (settings.Recursive)
|
AddChildDirectories(settings, currentDirectory, directoryStack);
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach (DirectoryInfo childDirectory in currentDirectory.EnumerateDirectories())
|
|
||||||
directoryStack.Push(childDirectory);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
AnsiConsole.MarkupLineInterpolated($"[red]Error:[/] {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -142,6 +131,22 @@ internal sealed class ListCommand : AsyncCommand<ListSettings>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void AddChildDirectories(ListSettings settings, DirectoryInfo directory, Stack<DirectoryInfo> stack)
|
||||||
|
{
|
||||||
|
if (!settings.Recursive)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (DirectoryInfo childDirectory in directory.EnumerateDirectories())
|
||||||
|
stack.Push(childDirectory);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
AnsiConsole.MarkupLineInterpolated($"[red]Error:[/] {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static string ByteSpanToString(ReadOnlySpan<byte> buffer)
|
private static string ByteSpanToString(ReadOnlySpan<byte> buffer)
|
||||||
{
|
{
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
|
Loading…
Reference in New Issue
Block a user