forked from datalust/seqcli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListCommand.cs
More file actions
40 lines (34 loc) · 1.19 KB
/
ListCommand.cs
File metadata and controls
40 lines (34 loc) · 1.19 KB
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
using System;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
using SeqCli.Config;
namespace SeqCli.Cli.Commands.ExpressionIndex;
[Command("expressionindex", "list", "List expression indexes", Example="seqcli expressionindex list")]
class ListCommand : Command
{
readonly ConnectionFeature _connection;
readonly OutputFormatFeature _output;
readonly StoragePathFeature _storagePath;
string? _id;
public ListCommand()
{
Options.Add(
"i=|id=",
"The id of a single expression index to list",
id => _id = id);
_output = Enable<OutputFormatFeature>();
_storagePath = Enable<StoragePathFeature>();
_connection = Enable<ConnectionFeature>();
}
protected override async Task<int> Run()
{
var config = RuntimeConfigurationLoader.Load(_storagePath);
var connection = SeqConnectionFactory.Connect(_connection, config);
var list = _id is not null
? [await connection.ExpressionIndexes.FindAsync(_id)]
: await connection.ExpressionIndexes.ListAsync();
_output.GetOutputFormat(config).ListEntities(list);
return 0;
}
}