tazel
A build system for C, C++, Objective-C, Objective-C++ and Zig, with C# project files.
Clonegit clone https://git.progmasoft.com/tazel
Remove tazel portal-modules search and info commands
- Commit
83947aad7e5fa95bca3374ccee1c2445f5dbb3ab- Author
- Leitwolf11 ·
- Parents
7a5ca0a4b768
Changes
CHANGELOG.md | 3 + docs/commands.md | 13 ----- src/Progmasoft.Tazel/Cli/CommandLine.cs | 16 +----- src/Progmasoft.Tazel/Cli/CommandMakers.cs | 37 ------------- src/Progmasoft.Tazel/Cli/CommandTypes.cs | 10 ---- src/Progmasoft.Tazel/Cli/Commands.cs | 1 - src/Progmasoft.Tazel/Cli/Help.cs | 14 ----- src/Progmasoft.Tazel/Cli/MoreCommands.cs | 64 ---------------------- .../Cli/ShellCompletion.FishPowerShell.cs | 3 - src/Progmasoft.Tazel/Cli/ShellCompletion.cs | 8 --- .../Progmasoft.Tazel.Tests/QueryAndPortalTests.cs | 56 +------------------ 11 files changed, 7 insertions(+), 218 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75d9c36..17c57ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ ## Unreleased +- Removed `tazel portal-modules search` and `tazel portal-modules info` (and their `-e`/`--exact` flag); dependency + resolution and `tazel vendor` continue to read Tazel Portal Modules. + - `query`, `cquery`, and `aquery` now support `--output` types `label`, `labelkind`, `build`, `package`, `location`, `graph`, `xml`, `proto`, `streamedproto`, `streamed-jsonproto`, `csx`/`C#`, `minrank`, and `maxrank` (no underscores; `label_kind` suggests `labelkind`, `starlark` suggests `csx`). diff --git a/docs/commands.md b/docs/commands.md index cb3421e..473f656 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -18,7 +18,6 @@ | `tazel log cache\|workspace\|what-ran\|what-failed\|what-up\|snoop\|daemon\|registries` | read-only inspection of cache, module root, recent runs, daemon status, and effective registries | | `tazel fetch` | downloads and checks the modules and plugins the module depends on, without building | | `tazel vendor` | copies the modules of Tazel Portal Modules and their indexes into `vendor/` | -| `tazel portal-modules search\|info [-e] [--] <module\|group:module>` | searches Tazel Portal Modules, or shows one module | | `tazel clean [--expunge] [--dry-run]` | removes the outputs, the test logs, zig's cache and the compiled project files; `--expunge` removes all of `.tazel`; `--dry-run` lists what would be removed without deleting | | `tazel cache keygen [--algorithm ed25519\|rsa-4096\|ml-dsa]` | prints a key pair for signing the results of a remote cache ([Remote cache](remote-cache.md)) | | `tazel cache validate [--remote]` | checks the records of `.tazel`, and with `--remote` the remote cache and its keys; changes nothing | @@ -432,18 +431,6 @@ that anything asks for, from the indexes `$group/$module/index.json`; a yanked v Each archive is checked against its `.sha256sums` and unpacked once below `.tazel/external`. `tazel vendor` copies the archives and the indexes into `vendor/`, and a build reads `vendor/` first, so a module with it builds offline. -```text -tazel portal-modules search json -tazel portal-modules search com.example:json -e -tazel portal-modules info json -tazel portal-modules info --exact -- com.example:json -``` - -`search` lists the modules whose `group:module` holds the query, from `index.json` at the top of the portal; with -`-e`/`--exact` only that one, and the group is required. `info` prints the versions of one module, yanked ones marked, -with their push dates and dependencies; without `-e` the group may be left out unless the name is a module of more -than one group. `--` ends the options, so a query may start with a dash. - ## tazel_envs.txt ```text diff --git a/src/Progmasoft.Tazel/Cli/CommandLine.cs b/src/Progmasoft.Tazel/Cli/CommandLine.cs index 2d29567..115c993 100644 --- a/src/Progmasoft.Tazel/Cli/CommandLine.cs +++ b/src/Progmasoft.Tazel/Cli/CommandLine.cs @@ -21,7 +21,7 @@ internal static class CommandLine /// <summary>The commands, as <c>tazel help</c> lists them.</summary> public static IReadOnlyList<string> Commands { get; } = ["build", "run", "test", "coverage", "query", "cquery", "aquery", "new", "init", "git", "log", "fetch", "vendor", "clean", "package", "custom", - "portal-modules", "cache", "explain", "version", "help", "license", "shell-completion", "dotnet", "limited-time", "options", "custom-cmds", "envs", "tool", "ignore"]; + "cache", "explain", "version", "help", "license", "shell-completion", "dotnet", "limited-time", "options", "custom-cmds", "envs", "tool", "ignore"]; private static readonly string[] Building = ["build", "run", "test", "coverage", "cquery", "aquery"]; @@ -60,7 +60,6 @@ internal static class CommandLine new("expunge", OptionKind.Flag, null, "clean"), new("short", OptionKind.Flag, null, "help", "explain"), new("long", OptionKind.Flag, null, "help", "explain"), - new("exact", OptionKind.Flag, null, "portal-modules"), new("algorithm", OptionKind.Value, ["ed25519", "rsa-4096", "ml-dsa"], "cache"), new("output", OptionKind.Value, null, "query", "cquery", "aquery", "license", "version"), ]; @@ -105,13 +104,6 @@ internal static class CommandLine return new HelpCommand(output, command); } - if (command == "portal-modules") - { - // After -- a query may start with a dash. - scanned.Positional.AddRange(scanned.AfterDashes); - scanned.AfterDashes.Clear(); - } - if (scanned.AfterDashes.Count > 0 && command != "run") { throw new CommandLineException($"tazel {command} takes nothing after --; only tazel run passes arguments on"); @@ -327,12 +319,6 @@ internal static class CommandLine return; } - if (argument == "-e") - { - seen.Add((Options.First(o => o.Long == "exact"), [], "-e")); - return; - } - if (argument == "-V") { seen.Add((Options.First(o => o.Long == "verbose"), [], "-V")); diff --git a/src/Progmasoft.Tazel/Cli/CommandMakers.cs b/src/Progmasoft.Tazel/Cli/CommandMakers.cs index 9652c99..c787617 100644 --- a/src/Progmasoft.Tazel/Cli/CommandMakers.cs +++ b/src/Progmasoft.Tazel/Cli/CommandMakers.cs @@ -29,7 +29,6 @@ internal static class CommandMakers ["explain"] = (scanned, output) => Explain(output, scanned.Positional, scanned.Has("short"), scanned.Has("long")), ["fetch"] = (scanned, output) => Bare(scanned, new FetchCommand(output)), ["vendor"] = (scanned, output) => Bare(scanned, new VendorCommand(output)), - ["portal-modules"] = (scanned, output) => PortalModules(output, scanned.Positional, scanned.Has("exact")), ["clean"] = (scanned, output) => Bare(scanned, new CleanCommand(output, scanned.Has("expunge"), scanned.Has("dry-run"))), ["package"] = (scanned, output) => Bare(scanned, new PackageCommand(output, scanned.Has("list"), scanned.Has("allow-dirty"), scanned.Last("output-dir"))), ["custom"] = (scanned, output) => scanned.Positional.Count == 0 @@ -339,42 +338,6 @@ internal static class CommandMakers return flags; } - /// <summary>A query is module or group:module, and group:module with --exact.</summary> - private static void CheckModuleQuery(string action, string query, bool exact) - { - var parts = query.Split(':'); - if (exact && (parts.Length != 2 || parts[0].Length == 0)) - { - throw new CommandLineException( - $"with -e or --exact, tazel portal-modules {action} needs the group too: group:{query.TrimStart(':')}"); - } - - if (parts.Length > 2 || parts.Any(part => part.Length == 0)) - { - throw new CommandLineException($"'{query}' is not module or group:module"); - } - } - - private static PortalModulesCommand PortalModules(OutputOptions output, List<string> positional, bool exact) - { - var actions = new[] { "search", "info" }; - if (positional.Count == 0 || !actions.Contains(positional[0], StringComparer.Ordinal)) - { - var near = positional.Count > 0 ? Suggestions.Nearest(positional[0], actions) : null; - throw new CommandLineException( - $"tazel portal-modules takes search or info{(near is null ? "" : $"; did you mean {near}?")}"); - } - - if (positional.Count != 2) - { - throw new CommandLineException($"tazel portal-modules {positional[0]} takes one module: module or group:module"); - } - - var query = positional[1]; - CheckModuleQuery(positional[0], query, exact); - return new PortalModulesCommand(output, positional[0] == "search" ? PortalAction.Search : PortalAction.Info, query, exact); - } - private static Command MakeShellCompletion(ScannedCommand scanned, OutputOptions output) { if (scanned.Positional.Count != 1) diff --git a/src/Progmasoft.Tazel/Cli/CommandTypes.cs b/src/Progmasoft.Tazel/Cli/CommandTypes.cs index 5cf69c1..1a04323 100644 --- a/src/Progmasoft.Tazel/Cli/CommandTypes.cs +++ b/src/Progmasoft.Tazel/Cli/CommandTypes.cs @@ -144,16 +144,6 @@ internal sealed record MigrateCommand(OutputOptions Output) : Command(Output); internal sealed record VendorCommand(OutputOptions Output) : Command(Output); -/// <summary>Searching Tazel Portal Modules, or the versions of one module.</summary> -internal enum PortalAction -{ - Search, - Info, -} - -internal sealed record PortalModulesCommand(OutputOptions Output, PortalAction Action, string Query, bool Exact) - : Command(Output); - internal sealed record DaemonCommand(OutputOptions Output, string Action) : Command(Output); /// <summary><c>tazel new <name> [--force]</c>: creates a new module in a new directory.</summary> diff --git a/src/Progmasoft.Tazel/Cli/Commands.cs b/src/Progmasoft.Tazel/Cli/Commands.cs index a46f764..8f2abc9 100644 --- a/src/Progmasoft.Tazel/Cli/Commands.cs +++ b/src/Progmasoft.Tazel/Cli/Commands.cs @@ -42,7 +42,6 @@ internal sealed partial class Commands(Reporter reporter, string workingDirector QueryCommand query => QueryAsync(query), FetchCommand => FetchAsync(), VendorCommand => VendorAsync(cancel), - PortalModulesCommand portal => PortalModulesAsync(portal, cancel), PackageCommand package => PackageAsync(package), GitAddCommand => new GitCommands(reporter, workingDirectory).AddAsync(TazelVersion), NewCommand create => Task.FromResult(new NewInitCommands(reporter, workingDirectory).New(create.Name, create.Force)), diff --git a/src/Progmasoft.Tazel/Cli/Help.cs b/src/Progmasoft.Tazel/Cli/Help.cs index 7cdbac0..f202c0c 100644 --- a/src/Progmasoft.Tazel/Cli/Help.cs +++ b/src/Progmasoft.Tazel/Cli/Help.cs @@ -132,20 +132,6 @@ internal static class Help Copies every module of Tazel Portal Modules the module depends on into vendor/, with its .sha256sums. Builds take an archive from vendor/ before they download it, so a module with vendor/ builds offline. """), - ["portal-modules"] = new("tazel portal-modules search|info [-e] [--] <module|group:module>: Tazel Portal Modules.", """ - tazel portal-modules search [-e|--exact] [--] <module|group:module> - tazel portal-modules info [-e|--exact] [--] <module|group:module> - - search lists the modules whose group:module holds the query; info prints the versions of one module, with - yanked ones marked, their push dates and dependencies. - -e, --exact only group:module, exactly; the group is required with it - Without -e the group may be left out; for info, a name that is a module of more than one group needs it. - -- ends the options, so a query may start with a dash. - - Examples: - tazel portal-modules search json - tazel portal-modules info com.example:json -e - """), ["clean"] = new("tazel clean [--expunge]: removes what builds made.", """ tazel clean [--expunge] diff --git a/src/Progmasoft.Tazel/Cli/MoreCommands.cs b/src/Progmasoft.Tazel/Cli/MoreCommands.cs index 48945c2..ce44dd7 100644 --- a/src/Progmasoft.Tazel/Cli/MoreCommands.cs +++ b/src/Progmasoft.Tazel/Cli/MoreCommands.cs @@ -293,68 +293,4 @@ internal sealed partial class Commands : $"vendor/ holds the {modules.Count} module{(modules.Count == 1 ? "" : "s")} of Tazel Portal Modules the module needs"); return 0; } - - private async Task<int> PortalModulesAsync(PortalModulesCommand command, CancellationToken cancel) - { - using var client = new PortalModulesClient(); - var colon = command.Query.IndexOf(':', StringComparison.Ordinal); - var group = colon < 0 ? null : command.Query[..colon]; - var name = colon < 0 ? command.Query : command.Query[(colon + 1)..]; - if (command.Action == PortalAction.Search) - { - return await SearchAsync(client, command, group, name, cancel).ConfigureAwait(false); - } - - group ??= await GroupOfAsync(client, name, cancel).ConfigureAwait(false); - var index = await client.IndexAsync(group, name, cancel).ConfigureAwait(false) - ?? throw new ProjectException($"Tazel Portal Modules has no module {group}:{name}"); - ShowModule(index); - return 0; - } - - private async Task<int> SearchAsync( - PortalModulesClient client, PortalModulesCommand command, string? group, string name, CancellationToken cancel) - { - var catalog = await client.CatalogAsync(cancel).ConfigureAwait(false); - var found = catalog.Modules.Where(entry => command.Exact - ? entry.Group == group && entry.Module == name - : $"{entry.Group}:{entry.Module}".Contains(command.Query, StringComparison.OrdinalIgnoreCase)) - .OrderBy(entry => entry.Group, StringComparer.Ordinal).ThenBy(entry => entry.Module, StringComparer.Ordinal).ToList(); - if (found.Count == 0) - { - reporter.Warning($"Tazel Portal Modules has no module that matches {command.Query}"); - return 1; - } - - reporter.Table(["Module", "Latest", "Description"], - found.Select(entry => (IReadOnlyList<string>)[$"{entry.Group}:{entry.Module}", entry.Latest ?? "", entry.Description ?? ""]) - .ToList()); - return 0; - } - - /// <summary>The group of a module named without one, which must be the only module of that name.</summary> - private static async Task<string> GroupOfAsync(PortalModulesClient client, string name, CancellationToken cancel) - { - var catalog = await client.CatalogAsync(cancel).ConfigureAwait(false); - var groups = catalog.Modules.Where(entry => entry.Module == name).Select(entry => entry.Group).Distinct().Order().ToList(); - return groups.Count switch - { - 0 => throw new ProjectException($"Tazel Portal Modules has no module {name}"), - 1 => groups[0], - _ => throw new CommandLineException($"{name} is a module of {string.Join(", ", groups)}; write the group: group:{name}"), - }; - } - - /// <summary>A module's latest version and a table of its versions, newest first.</summary> - private void ShowModule(ModuleIndex index) - { - var highest = PortalModulesClient.Highest(index); - reporter.Strong($"{index.Group}:{index.Module}" + (highest is null ? "" : $" latest {highest.Version}")); - reporter.Table(["Version", "Pushed", "Dependencies"], index.Versions.Reverse().Select(version => (IReadOnlyList<string>) - [ - version.Version + (version.Yanked ? " yanked" : ""), - version.Pushed.UtcDateTime.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), - string.Join(", ", version.Dependencies.Select(d => $"{d.Group}:{d.Module} {d.Version}{(d.Test ? " (test)" : "")}")), - ]).ToList()); - } } diff --git a/src/Progmasoft.Tazel/Cli/ShellCompletion.FishPowerShell.cs b/src/Progmasoft.Tazel/Cli/ShellCompletion.FishPowerShell.cs index d775b7d..f484ecf 100644 --- a/src/Progmasoft.Tazel/Cli/ShellCompletion.FishPowerShell.cs +++ b/src/Progmasoft.Tazel/Cli/ShellCompletion.FishPowerShell.cs @@ -118,8 +118,6 @@ internal static class FishPowerShellCompletions sb.AppendLine("complete -c tazel -n '__tazel_needs_subcmd tool' -a 'launch create-wrapper'"); AppendFishValueOption(sb, "__fish_seen_subcommand_from tool", "output-dir", null, "Output directory", shortOpt: "o", requireFiles: true); sb.AppendLine("complete -c tazel -n '__tazel_needs_subcmd ignore' -a 'create-from validate add delete del'"); - sb.AppendLine("complete -c tazel -n '__tazel_needs_subcmd portal-modules' -a 'search info'"); - sb.AppendLine("complete -c tazel -n '__fish_seen_subcommand_from portal-modules' -s e -l exact -d 'Exact match'"); sb.AppendLine("complete -c tazel -n '__tazel_needs_subcmd limited-time' -a 'C#'"); return sb.ToString().TrimEnd(); } @@ -234,7 +232,6 @@ internal static class FishPowerShellCompletions 'envs' { $candidates += @('--user', '--project', '--local'); if ($null -eq $subcmd) { $candidates += @('validate') } } 'tool' { $candidates += @('--output-dir', '-o'); if ($null -eq $subcmd) { $candidates += @('launch', 'create-wrapper') } } 'ignore' { if ($null -eq $subcmd) { $candidates += @('create-from', 'validate', 'add', 'delete', 'del') } } - 'portal-modules' { $candidates += @('--exact', '-e'); if ($null -eq $subcmd) { $candidates += @('search', 'info') } } 'limited-time' { if ($null -eq $subcmd) { $candidates += @('C#') } } } } diff --git a/src/Progmasoft.Tazel/Cli/ShellCompletion.cs b/src/Progmasoft.Tazel/Cli/ShellCompletion.cs index 2b6ad2c..f3a7164 100644 --- a/src/Progmasoft.Tazel/Cli/ShellCompletion.cs +++ b/src/Progmasoft.Tazel/Cli/ShellCompletion.cs @@ -69,7 +69,6 @@ internal static class ShellCompletion ("clean", "Remove build outputs"), ("package", "Create a module archive"), ("custom", "Run a custom command from tazel_custom.txt"), - ("portal-modules", "Search or inspect Tazel Portal Modules"), ("cache", "Manage remote cache keys and validate or repair caches"), ("explain", "Explain an error code"), ("version", "Print the Tazel version"), @@ -284,10 +283,6 @@ internal static class ShellCompletion ignore) if [[ -z "$subcmd" ]]; then words="$words create-from validate add delete del"; fi ;; - portal-modules) - words="$words --exact -e" - if [[ -z "$subcmd" ]]; then words="$words search info"; fi - ;; limited-time) if [[ -z "$subcmd" ]]; then words="$words C#"; fi ;; @@ -399,9 +394,6 @@ internal static class ShellCompletion sb.AppendLine(" ignore)"); sb.AppendLine(" _arguments $global_opts '1:action:(create-from validate add delete del)'"); sb.AppendLine(" ;;"); - sb.AppendLine(" portal-modules)"); - sb.AppendLine(" _arguments $global_opts '1:action:(search info)' '(-e --exact)'{-e,--exact}'[Exact match]'"); - sb.AppendLine(" ;;"); sb.AppendLine(" limited-time)"); sb.AppendLine(" _arguments $global_opts '1:migration:(C#)'"); sb.AppendLine(" ;;"); diff --git a/tests/Progmasoft.Tazel.Tests/QueryAndPortalTests.cs b/tests/Progmasoft.Tazel.Tests/QueryAndPortalTests.cs index d9cd733..6435933 100644 --- a/tests/Progmasoft.Tazel.Tests/QueryAndPortalTests.cs +++ b/tests/Progmasoft.Tazel.Tests/QueryAndPortalTests.cs @@ -120,28 +120,10 @@ public sealed class HelpTests public sealed class PortalCommandLineTests { [Theory] - [InlineData(new[] { "portal-modules", "search", "json" }, "search", "json", false)] - [InlineData(new[] { "portal-modules", "search", "com.example:json", "-e" }, "search", "com.example:json", true)] - [InlineData(new[] { "portal-modules", "search", "com.example:json", "--exact" }, "search", "com.example:json", true)] - [InlineData(new[] { "portal-modules", "search", "--", "-json" }, "search", "-json", false)] - [InlineData(new[] { "portal-modules", "search", "-e", "--", "com.example:json" }, "search", "com.example:json", true)] - [InlineData(new[] { "portal-modules", "info", "json" }, "info", "json", false)] - [InlineData(new[] { "portal-modules", "info", "--exact", "--", "com.example:json" }, "info", "com.example:json", true)] - public void ReadsSearchAndInfo(string[] arguments, string action, string query, bool exact) - { - var command = Assert.IsType<PortalModulesCommand>(CommandLine.Parse(arguments)); - Assert.Equal(action == "search" ? PortalAction.Search : PortalAction.Info, command.Action); - Assert.Equal(query, command.Query); - Assert.Equal(exact, command.Exact); - } - - [Theory] - [InlineData(new[] { "portal-modules", "search", "json", "-e" }, "needs the group too: group:json")] - [InlineData(new[] { "portal-modules", "info", "-e", "--", "json" }, "needs the group too")] - [InlineData(new[] { "portal-modules", "serch", "json" }, "did you mean search?")] - [InlineData(new[] { "portal-modules", "info", "a:b:c" }, "is not module or group:module")] + [InlineData(new[] { "portal-modules", "search", "json" }, "is not a command of tazel")] + [InlineData(new[] { "portal-modules", "info", "json" }, "is not a command of tazel")] [InlineData(new[] { "fetch", "x" }, "tazel fetch takes no 'x'")] - [InlineData(new[] { "build", "--exact" }, "--exact is not an option of tazel build")] + [InlineData(new[] { "build", "--exact" }, "--exact is not an option")] public void RefusesWhatIsWrong(string[] arguments, string message) { var error = Assert.Throws<CommandLineException>(() => CommandLine.Parse(arguments)); @@ -342,38 +324,6 @@ public sealed class PortalTests Assert.Contains("the index of com.example:json: '..' is not the name of a module", error.Message, StringComparison.Ordinal); } - [Fact] - public async Task SearchesAndShowsModules() - { - using var served = new TemporaryModule(); - using var portal = new FakePortal(served.Root); - portal.Push("com.example", "json", "1.0.0", Library); - portal.Push("com.example", "json", "1.1.0", Library); - portal.Push("org.other", "json", "0.1.0", Library); - portal.Catalog(("com.example", "json", "1.1.0", "JSON for C"), ("org.other", "json", "0.1.0", "Another"), - ("com.example", "yaml", "0.2.0", "YAML")); - using var module = new TemporaryModule(); - using var address = new EnvironmentVariable("TAZEL_PORTAL_MODULES_URL", portal.Address); - - var (status, output) = await module.TazelAsync(".", "portal-modules", "search", "json"); - Assert.True(status == 0, output); - Assert.Contains("com.example:json", output, StringComparison.Ordinal); - Assert.Contains("org.other:json", output, StringComparison.Ordinal); - Assert.DoesNotContain("yaml", output, StringComparison.Ordinal); - - (status, output) = await module.TazelAsync(".", "portal-modules", "search", "com.example:json", "-e"); - Assert.True(status == 0, output); - Assert.DoesNotContain("org.other", output, StringComparison.Ordinal); - - (status, output) = await module.TazelAsync(".", "portal-modules", "info", "json"); - Assert.Equal(2, status); - Assert.Contains("json is a module of com.example, org.other; write the group", output, StringComparison.Ordinal); - - (status, output) = await module.TazelAsync(".", "portal-modules", "info", "com.example:json", "--exact"); - Assert.True(status == 0, output); - Assert.Contains("latest 1.1.0", output, StringComparison.Ordinal); - Assert.Contains("1.0.0", output, StringComparison.Ordinal); - } } /// <summary>Sets an environment variable for one test and puts it back.</summary>