Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit b0bb2b7

Browse files
authored
Merge pull request #35 from Inedo/clarify-repack
Deprecate most parameters on repack.
2 parents 5c5e52e + 889d159 commit b0bb2b7

File tree

5 files changed

+67
-64
lines changed

5 files changed

+67
-64
lines changed

README.md

+5-12
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Extracts the contents of a ProGet universal package to a directory.
4848
- **`target`** - Directory where the contents of the package will be extracted.
4949
- `overwrite` - When specified, overwrite files in the target directory.
5050

51-
5251
### install
5352

5453
Downloads the specified ProGet universal package and extracts its contents to a directory.
@@ -77,22 +76,16 @@ Lists packages installed in the local registry.
7776

7877
### repack
7978

80-
Creates a new ProGet universal package from an existing package with optionally modified metadata.
79+
Creates a new ProGet universal package by repackaging an existing package with a new version number and audit information.
8180

82-
upack repack «source» [--manifest=«manifest»] [--targetDirectory=«targetDirectory»] [--group=«group»] [--name=«name»] [--version=«version»] [--title=«title»] [--description=«description»] [--icon=«icon»] [--overwrite]
81+
upack repack «source» [--newVersion=«newVersion»] [--targetDirectory=«targetDirectory»] [--note=«auditNote»] [--overwrite]
8382

8483
- **`source`** - The path of the existing upack file.
85-
- `manifest` - Path of upack.json file to merge.
86-
- `targetDirectory` - Directory where the .upack file will be created. If not specified, the current working directory is used.
87-
- `group` - Package group. If metadata file is provided, value will be ignored.
88-
- `name` - Package name. If metadata file is provided, value will be ignored.
89-
- `version` - Package version. If metadata file is provided, value will be ignored.
90-
- `title` - Package title. If metadata file is provided, value will be ignored.
91-
- `description` - Package description. If metadata file is provided, value will be ignored.
92-
- `icon` - Icon absolute Url. If metadata file is provided, value will be ignored.
84+
- `newVersion` - New package version to use.
85+
- `targetDirectory` - Directory where the .upack file will be created. If not specified, the current working directory is used.
86+
- `note` - A description of the purpose for repackaging that will be entered as the audit note.
9387
- `overwrite` - Overwrite existing package file if it already exists.
9488

95-
9689
### verify
9790

9891
Verifies that a specified package hash matches the hash stored in a ProGet Universal feed.

src/dotnet/upack/Command.cs

+9-4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ internal Argument(PropertyInfo p)
6161
this.p = p;
6262
}
6363

64+
public bool IsDeprecated => p.GetCustomAttribute<ObsoleteAttribute>() != null;
6465
public abstract bool Optional { get; }
6566
public string DisplayName => p.GetCustomAttribute<DisplayNameAttribute>()?.DisplayName ?? p.Name;
6667
public string Description => p.GetCustomAttribute<DescriptionAttribute>()?.Description ?? string.Empty;
@@ -200,12 +201,14 @@ public string GetUsage()
200201

201202
foreach (var arg in this.PositionalArguments)
202203
{
203-
s.Append(' ').Append(arg.GetUsage());
204+
if (!arg.IsDeprecated)
205+
s.Append(' ').Append(arg.GetUsage());
204206
}
205207

206208
foreach (var arg in this.ExtraArguments)
207209
{
208-
s.Append(' ').Append(arg.GetUsage());
210+
if (!arg.IsDeprecated)
211+
s.Append(' ').Append(arg.GetUsage());
209212
}
210213

211214
return s.ToString();
@@ -219,12 +222,14 @@ public string GetHelp()
219222

220223
foreach (var arg in this.PositionalArguments)
221224
{
222-
s.AppendLine().Append(arg.GetHelp());
225+
if (!arg.IsDeprecated)
226+
s.AppendLine().Append(arg.GetHelp());
223227
}
224228

225229
foreach (var arg in this.ExtraArguments)
226230
{
227-
s.AppendLine().Append(arg.GetHelp());
231+
if (!arg.IsDeprecated)
232+
s.AppendLine().Append(arg.GetHelp());
228233
}
229234

230235
return s.ToString();

src/dotnet/upack/Repack.cs

+23-20
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
namespace Inedo.ProGet.UPack
1414
{
1515
[DisplayName("repack")]
16-
[Description("Creates a new ProGet universal package from an existing package with optionally modified metadata.")]
16+
[Description("Creates a new ProGet universal package by repackaging an existing package with a new version number and audit information.")]
1717
public sealed class Repack : Command
1818
{
19-
[DisplayName("manifest")]
19+
[Obsolete]
20+
[AlternateName("manifest")]
2021
[AlternateName("metadata")]
21-
[Description("Path of upack.json file to merge.")]
2222
[ExtraArgument]
2323
[ExpandPath]
2424
public string Manifest { get; set; }
@@ -35,44 +35,45 @@ public sealed class Repack : Command
3535
[ExpandPath]
3636
public string TargetDirectory { get; set; }
3737

38-
[DisplayName("group")]
39-
[Description("Package group. If metadata file is provided, value will be ignored.")]
38+
[Obsolete]
39+
[AlternateName("group")]
4040
[ExtraArgument]
4141
public string Group { get; set; }
4242

43-
[DisplayName("name")]
44-
[Description("Package name. If metadata file is provided, value will be ignored.")]
43+
[Obsolete]
44+
[AlternateName("name")]
4545
[ExtraArgument]
4646
public string Name { get; set; }
4747

48-
[DisplayName("version")]
49-
[Description("Package version. If metadata file is provided, value will be ignored.")]
48+
[DisplayName("newVersion")]
49+
[AlternateName("version")]
50+
[Description("New package version to use.")]
5051
[ExtraArgument]
51-
public string Version { get; set; }
52+
public string NewVersion { get; set; }
5253

53-
[DisplayName("title")]
54-
[Description("Package title. If metadata file is provided, value will be ignored.")]
54+
[Obsolete]
55+
[AlternateName("title")]
5556
[ExtraArgument]
5657
public string Title { get; set; }
5758

58-
[DisplayName("description")]
59-
[Description("Package description. If metadata file is provided, value will be ignored.")]
59+
[Obsolete]
60+
[AlternateName("description")]
6061
[ExtraArgument]
6162
public string PackageDescription { get; set; }
6263

63-
[DisplayName("icon")]
64-
[Description("Icon absolute Url. If metadata file is provided, value will be ignored.")]
64+
[Obsolete]
65+
[AlternateName("icon")]
6566
[ExtraArgument]
6667
public string IconUrl { get; set; }
6768

68-
[DisplayName("no-audit")]
69-
[Description("Do not store audit information in the UPack manifest.")]
69+
[Obsolete]
70+
[AlternateName("no-audit")]
7071
[ExtraArgument]
7172
[DefaultValue(false)]
7273
public bool NoAudit { get; set; }
7374

7475
[DisplayName("note")]
75-
[Description("A description of the purpose for creating this upack file.")]
76+
[Description("A description of the purpose for repackaging that will be entered as the audit note.")]
7677
[ExtraArgument]
7778
public string Note { get; set; }
7879

@@ -82,6 +83,7 @@ public sealed class Repack : Command
8283
[DefaultValue(false)]
8384
public bool Overwrite { get; set; }
8485

86+
#pragma warning disable CS0612 // Type or member is obsolete
8587
public override async Task<int> RunAsync(CancellationToken cancellationToken)
8688
{
8789
if (this.NoAudit && !string.IsNullOrEmpty(this.Note))
@@ -185,7 +187,7 @@ private async Task<UniversalPackageMetadata> GetMetadataToMergeAsync()
185187
{
186188
Group = this.Group,
187189
Name = this.Name,
188-
Version = UniversalPackageVersion.TryParse(this.Version),
190+
Version = UniversalPackageVersion.TryParse(this.NewVersion),
189191
Title = this.Title,
190192
Description = this.PackageDescription,
191193
Icon = this.IconUrl
@@ -206,5 +208,6 @@ private async Task<UniversalPackageMetadata> GetMetadataToMergeAsync()
206208
}
207209
}
208210
}
211+
#pragma warning restore CS0612 // Type or member is obsolete
209212
}
210213
}

src/go/upack/command.go

+16-8
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,17 @@ func defaultCommandUsage(cmd Command) string {
163163
s = append(s, cmd.Name()...)
164164

165165
for _, arg := range cmd.PositionalArguments() {
166-
s = append(s, ' ')
167-
s = append(s, arg.Usage()...)
166+
if arg.Name != "" {
167+
s = append(s, ' ')
168+
s = append(s, arg.Usage()...)
169+
}
168170
}
169171

170172
for _, arg := range cmd.ExtraArguments() {
171-
s = append(s, ' ')
172-
s = append(s, arg.Usage()...)
173+
if arg.Name != "" {
174+
s = append(s, ' ')
175+
s = append(s, arg.Usage()...)
176+
}
173177
}
174178

175179
return string(s)
@@ -184,13 +188,17 @@ func defaultCommandHelp(cmd Command) string {
184188
s = append(s, '\n')
185189

186190
for _, arg := range cmd.PositionalArguments() {
187-
s = append(s, '\n')
188-
s = append(s, arg.Help()...)
191+
if arg.Name != "" {
192+
s = append(s, '\n')
193+
s = append(s, arg.Help()...)
194+
}
189195
}
190196

191197
for _, arg := range cmd.ExtraArguments() {
192-
s = append(s, '\n')
193-
s = append(s, arg.Help()...)
198+
if arg.Name != "" {
199+
s = append(s, '\n')
200+
s = append(s, arg.Help()...)
201+
}
194202
}
195203

196204
return string(s)

src/go/upack/repack.go

+14-20
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Repack struct {
2727

2828
func (*Repack) Name() string { return "repack" }
2929
func (*Repack) Description() string {
30-
return "Creates a new ProGet universal package from an existing package with optionally modified metadata."
30+
return "Creates a new ProGet universal package by repackaging an existing package with a new version number and audit information."
3131
}
3232

3333
func (r *Repack) Help() string { return defaultCommandHelp(r) }
@@ -49,8 +49,7 @@ func (*Repack) PositionalArguments() []PositionalArgument {
4949
func (*Repack) ExtraArguments() []ExtraArgument {
5050
return []ExtraArgument{
5151
{
52-
Name: "manifest",
53-
Alias: []string{"metadata"},
52+
Alias: []string{"manifest", "metadata"},
5453
Description: "Path of upack.json file to merge.",
5554
TrySetValue: trySetPathValue("manifest", func(cmd Command) *string {
5655
return &cmd.(*Repack).Manifest
@@ -64,58 +63,53 @@ func (*Repack) ExtraArguments() []ExtraArgument {
6463
}),
6564
},
6665
{
67-
Name: "group",
68-
Description: "Package group. If metadata file is provided, value will be ignored.",
66+
Alias: []string{"group"},
6967
TrySetValue: trySetStringFnValue("group", func(cmd Command) func(string) {
7068
return (&cmd.(*Repack).Metadata).SetGroup
7169
}),
7270
},
7371
{
74-
Name: "name",
75-
Description: "Package name. If metadata file is provided, value will be ignored.",
72+
Alias: []string{"name"},
7673
TrySetValue: trySetStringFnValue("name", func(cmd Command) func(string) {
7774
return (&cmd.(*Repack).Metadata).SetName
7875
}),
7976
},
8077
{
81-
Name: "version",
82-
Description: "Package version. If metadata file is provided, value will be ignored.",
83-
TrySetValue: trySetStringFnValue("version", func(cmd Command) func(string) {
78+
Name: "newVersion",
79+
Alias: []string{"version"},
80+
Description: "New package version to use.",
81+
TrySetValue: trySetStringFnValue("newVersion", func(cmd Command) func(string) {
8482
return (&cmd.(*Repack).Metadata).SetVersion
8583
}),
8684
},
8785
{
88-
Name: "title",
89-
Description: "Package title. If metadata file is provided, value will be ignored.",
86+
Alias: []string{"title"},
9087
TrySetValue: trySetStringFnValue("title", func(cmd Command) func(string) {
9188
return (&cmd.(*Repack).Metadata).SetTitle
9289
}),
9390
},
9491
{
95-
Name: "description",
96-
Description: "Package description. If metadata file is provided, value will be ignored.",
92+
Alias: []string{"description"},
9793
TrySetValue: trySetStringFnValue("description", func(cmd Command) func(string) {
9894
return (&cmd.(*Repack).Metadata).SetDescription
9995
}),
10096
},
10197
{
102-
Name: "icon",
103-
Description: "Icon absolute Url. If metadata file is provided, value will be ignored.",
98+
Alias: []string{"icon"},
10499
TrySetValue: trySetStringFnValue("icon", func(cmd Command) func(string) {
105100
return (&cmd.(*Repack).Metadata).SetIconURL
106101
}),
107102
},
108103
{
109104
Name: "note",
110-
Description: "A description of the purpose for creating this upack file.",
105+
Description: "A description of the purpose for repackaging that will be entered as the audit note.",
111106
TrySetValue: trySetStringValue("note", func(cmd Command) *string {
112107
return &cmd.(*Repack).Note
113108
}),
114109
},
115110
{
116-
Name: "no-audit",
117-
Description: "Do not store audit information in the UPack manifest.",
118-
Flag: true,
111+
Alias: []string{"no-audit"},
112+
Flag: true,
119113
TrySetValue: trySetBoolValue("no-audit", func(cmd Command) *bool {
120114
return &cmd.(*Repack).NoAudit
121115
}),

0 commit comments

Comments
 (0)