-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDebugifiedListProvider.cs
55 lines (45 loc) · 1.74 KB
/
DebugifiedListProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.IO;
using CommandLine;
namespace alma.debugify
{
[Verb("list",
HelpText = "lists all nuget packages in the package cache that are debugified")]
public class ListCommand
{
[Option("verbose", Required = false, HelpText = "Set output to verbose messages.")]
public bool Verbose { get; set; }
}
internal class DebugifiedListProvider
{
private readonly ILogger _logger;
public DebugifiedListProvider(ILogger logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public void List(ListCommand cmd)
{
if (cmd == null) throw new ArgumentNullException(nameof(cmd));
var pathWithEnv = $@"%USERPROFILE%\.nuget\packages\";
var extractPath = Environment.ExpandEnvironmentVariables(pathWithEnv);
if (!Directory.Exists(extractPath))
{
_logger.Warning($"Could not find nuget package cache at {extractPath}");
return;
}
_logger.Info($"Listing all debugified packages at {extractPath}");
var count = 0;
// add pseudo file to know when do delete such a folder
foreach (var file in Directory.GetFiles(extractPath, ".debugified.txt", SearchOption.AllDirectories))
{
var dir = Path.GetDirectoryName(file);
_logger.Info($" - {dir.Substring(extractPath.Length, dir.Length - extractPath.Length)}");
count++;
}
if (count == 0)
_logger.Success("All good. Nothing debugified");
else
_logger.Success($"Found {count} debugified packages");
}
}
}