feat(management): additive Skip/Take paging on template/instance lists (arch-review P2)
Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
This commit is contained in:
@@ -212,19 +212,25 @@ public static class InstanceCommands
|
||||
var siteIdOption = new Option<int?>("--site-id") { Description = "Filter by site ID" };
|
||||
var templateIdOption = new Option<int?>("--template-id") { Description = "Filter by template ID" };
|
||||
var searchOption = new Option<string?>("--search") { Description = "Search term" };
|
||||
var skipOption = new Option<int>("--skip") { Description = "Offset paging: number of items to skip (default 0)" };
|
||||
var takeOption = new Option<int?>("--take") { Description = "Offset paging: max items to return (1..1000; omit for unlimited)" };
|
||||
|
||||
var cmd = new Command("list") { Description = "List instances" };
|
||||
cmd.Add(siteIdOption);
|
||||
cmd.Add(templateIdOption);
|
||||
cmd.Add(searchOption);
|
||||
cmd.Add(skipOption);
|
||||
cmd.Add(takeOption);
|
||||
cmd.SetAction(async (ParseResult result) =>
|
||||
{
|
||||
var siteId = result.GetValue(siteIdOption);
|
||||
var templateId = result.GetValue(templateIdOption);
|
||||
var search = result.GetValue(searchOption);
|
||||
var skip = result.GetValue(skipOption);
|
||||
var take = result.GetValue(takeOption);
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||
new ListInstancesCommand(siteId, templateId, search));
|
||||
new ListInstancesCommand(siteId, templateId, search, skip, take));
|
||||
});
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,19 @@ public static class TemplateCommands
|
||||
Description = "Include full template definitions (all attributes/alarms/scripts) in table output. "
|
||||
+ "Without it, table output is a compact summary (counts only). JSON output is always full."
|
||||
};
|
||||
var skipOption = new Option<int>("--skip") { Description = "Offset paging: number of items to skip (default 0)" };
|
||||
var takeOption = new Option<int?>("--take") { Description = "Offset paging: max items to return (1..1000; omit for unlimited)" };
|
||||
var cmd = new Command("list") { Description = "List all templates (compact table summary; use --detail for the full dump)" };
|
||||
cmd.Add(detailOption);
|
||||
cmd.Add(skipOption);
|
||||
cmd.Add(takeOption);
|
||||
cmd.SetAction(async (ParseResult result) =>
|
||||
{
|
||||
var detail = result.GetValue(detailOption);
|
||||
var skip = result.GetValue(skipOption);
|
||||
var take = result.GetValue(takeOption);
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new ListTemplatesCommand(),
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new ListTemplatesCommand(skip, take),
|
||||
tableProjector: detail ? null : TemplateTableProjection.ProjectSummary);
|
||||
});
|
||||
return cmd;
|
||||
|
||||
@@ -101,6 +101,8 @@ scadabridge --url <url> --format json template list # full JSON (always)
|
||||
| Option | Required | Description |
|
||||
|--------|----------|-------------|
|
||||
| `--detail` | no | Include full definitions in table output (no effect on JSON) |
|
||||
| `--skip` | no | Offset paging: number of items to skip (default 0) |
|
||||
| `--take` | no | Offset paging: max items to return (clamped 1..1000; omit for unlimited) |
|
||||
|
||||
#### `template get`
|
||||
|
||||
@@ -450,7 +452,7 @@ scadabridge --url <url> instance get --id <int>
|
||||
List instances, with optional filters.
|
||||
|
||||
```sh
|
||||
scadabridge --url <url> instance list [--site-id <int>] [--template-id <int>] [--search <string>]
|
||||
scadabridge --url <url> instance list [--site-id <int>] [--template-id <int>] [--search <string>] [--skip <int>] [--take <int>]
|
||||
```
|
||||
|
||||
| Option | Required | Description |
|
||||
@@ -458,6 +460,8 @@ scadabridge --url <url> instance list [--site-id <int>] [--template-id <int>] [-
|
||||
| `--site-id` | no | Filter by site ID |
|
||||
| `--template-id` | no | Filter by template ID |
|
||||
| `--search` | no | Search term matched against instance name |
|
||||
| `--skip` | no | Offset paging: number of items to skip (default 0). Applied after site-scope filtering. |
|
||||
| `--take` | no | Offset paging: max items to return (clamped 1..1000; omit for unlimited) |
|
||||
|
||||
#### `instance create`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user