/
AllVerb.cs
109 lines (96 loc) · 3.33 KB
/
AllVerb.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AllVerb.cs" company="Sundews">
// Copyright (c) Sundews. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Sundew.Packaging.Tool.PruneLocalSource;
using System.Collections.Generic;
using Sundew.CommandLine;
using Sundew.Packaging.Source;
/// <summary>
/// Verb for refering to all package ids.
/// </summary>
/// <seealso cref="Sundew.CommandLine.IVerb" />
public class AllVerb : IVerb
{
private readonly List<string> packageIds;
/// <summary>
/// Initializes a new instance of the <see cref="AllVerb"/> class.
/// </summary>
public AllVerb()
: this(new List<string> { "*" }, PackageSources.DefaultLocalSourceName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AllVerb"/> class.
/// </summary>
/// <param name="packageIds">The package ids.</param>
/// <param name="source">The source.</param>
/// <param name="verbose">if set to <c>true</c> [verbose].</param>
public AllVerb(List<string> packageIds, string source, bool verbose = false)
{
this.packageIds = packageIds;
this.Source = source;
this.Verbose = verbose;
}
/// <summary>
/// Gets the source.
/// </summary>
/// <value>
/// The source.
/// </value>
public string Source { get; private set; }
/// <summary>
/// Gets the package ids.
/// </summary>
/// <value>
/// The package ids.
/// </value>
public IReadOnlyList<string> PackageIds => this.packageIds;
/// <summary>
/// Gets a value indicating whether this <see cref="AllVerb"/> is verbose.
/// </summary>
/// <value>
/// <c>true</c> if verbose; otherwise, <c>false</c>.
/// </value>
public bool Verbose { get; private set; }
/// <summary>
/// Gets the next verb.
/// </summary>
/// <value>
/// The next verb.
/// </value>
public IVerb? NextVerb { get; } = default;
/// <summary>
/// Gets the name.
/// </summary>
/// <value>
/// The name.
/// </value>
public string Name { get; } = "all";
/// <summary>
/// Gets the short name.
/// </summary>
/// <value>
/// The short name.
/// </value>
public string? ShortName => default;
/// <summary>
/// Gets the help text.
/// </summary>
/// <value>
/// The help text.
/// </value>
public string HelpText { get; } = "Prune the specified local source for all packages";
/// <summary>
/// Configures the specified arguments builder.
/// </summary>
/// <param name="argumentsBuilder">The arguments builder.</param>
public void Configure(IArgumentsBuilder argumentsBuilder)
{
argumentsBuilder.AddOptionalList("p", "package-ids", this.packageIds, "The packages to prune (* Wildcards supported)");
argumentsBuilder.AddOptional("s", "source", () => this.Source, s => this.Source = s, @"Local source or source name to search for packages");
CommonOptions.AddVerbose(argumentsBuilder, this.Verbose, b => this.Verbose = b);
}
}