Skip to content

Commit 3c5681f

Browse files
committed
Rdx: Remove table mode, remove interactive mode
1 parent 86011c3 commit 3c5681f

File tree

2 files changed

+1
-184
lines changed

2 files changed

+1
-184
lines changed

SmartImage.Rdx/SearchCommand.cs

Lines changed: 1 addition & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, SearchComma
257257

258258
int act;
259259

260-
if (m_scs.TableFormat == OutputFields.None) {
261-
act = await RunSimpleAsync();
262-
}
263-
else {
264-
act = await RunTableAsync();
265-
266-
}
267-
268-
if (settings.Interactive.HasValue && settings.Interactive.Value) {
269-
act = await RunInteractiveAsync();
270-
271-
}
260+
act = await RunSimpleAsync();
272261

273262
return (int) act;
274263
}
@@ -312,164 +301,6 @@ private async Task<int> RunSimpleAsync()
312301
return EC_OK;
313302
}
314303

315-
private async Task<int> RunTableAsync()
316-
{
317-
var format = m_scs.TableFormat;
318-
var table = CliFormat.GetTableForFormat(format);
319-
320-
var live = AConsole.Live(table)
321-
.StartAsync(async (l) =>
322-
{
323-
324-
// Client.OnResult += OnResultComplete;
325-
326-
var run = Client.RunSearchAsync(Query, token: m_cts.Token);
327-
328-
while (await Client.ResultChannel.Reader.WaitToReadAsync()) {
329-
var sr = await Client.ResultChannel.Reader.ReadAsync();
330-
int i = 0;
331-
332-
var rm = new ResultModel(sr)
333-
{ };
334-
335-
m_results.Add(rm);
336-
337-
if (!sr.IsStatusSuccessful) {
338-
// Debugger.Break();
339-
var rows = rm.GetRowsForFormat(format);
340-
table.AddRow(rows);
341-
}
342-
else {
343-
var results = rm.GetRowsForFormat2(format);
344-
345-
foreach (IRenderable[] allResult in results) {
346-
table.AddRow(allResult);
347-
348-
}
349-
}
350-
351-
rm.UpdateGrid();
352-
353-
l.Refresh();
354-
}
355-
356-
await run;
357-
358-
// Client.OnResult -= OnResultComplete;
359-
return;
360-
361-
});
362-
363-
await live;
364-
365-
return EC_OK;
366-
}
367-
368-
public async Task<int> RunInteractiveAsync()
369-
{
370-
371-
AConsole.Clear();
372-
373-
//todo
374-
375-
int i = 0;
376-
var gr1 = new Grid();
377-
gr1.AddColumns(2);
378-
379-
foreach (ResultModel result in m_results) {
380-
gr1.AddRow($"{result.Result.Engine.Name}", $"{i++}");
381-
}
382-
383-
var res = m_results.ToArray();
384-
385-
ConsoleKeyInfo prompt = default;
386-
387-
const string L_ROOT = "Root";
388-
const string L_LEFT = "Left";
389-
390-
const string L_RIGHT = "Right";
391-
const string L_TOP = "Top";
392-
const string L_BOTTOM = "Bottom";
393-
394-
var layout = new Layout(L_ROOT)
395-
.SplitColumns(
396-
new Layout(L_LEFT, gr1) { },
397-
new Layout(L_RIGHT) { }
398-
.SplitRows(
399-
new Layout(L_TOP) { },
400-
new Layout(L_BOTTOM) { }));
401-
402-
do {
403-
// prompt = AConsole.Prompt(choices);
404-
405-
AConsole.Clear();
406-
layout[L_LEFT].Update(new Panel(gr1));
407-
AConsole.Write(layout);
408-
409-
prompt = Console.ReadKey(true);
410-
411-
var keyChar = prompt.KeyChar;
412-
var idx = (int) Char.GetNumericValue(keyChar);
413-
414-
var b = idx >= 0 && idx < res.Length;
415-
416-
if (b) {
417-
var rm = res[idx];
418-
Debug.WriteLine($"{prompt} {idx} {rm}");
419-
420-
if (Query.Uni == null) {
421-
throw new SmartImageException();
422-
}
423-
424-
var stream = Query.Uni.Stream;
425-
stream.TrySeek();
426-
427-
var gr2 = rm.UpdateGrid(clear: true);
428-
429-
// Update the left column
430-
layout[L_LEFT].Update(new Panel(rm.Grid));
431-
432-
// layout["Top"].Update(new Panel(gr2));
433-
434-
AConsole.Clear();
435-
AConsole.Write(layout);
436-
437-
do {
438-
prompt = Console.ReadKey(true);
439-
440-
if (prompt.Key == ConsoleKey.Backspace) {
441-
break;
442-
}
443-
444-
/*
445-
if (prompt.Key == ConsoleKey.Backspace) {
446-
continue;
447-
}*/
448-
var keyChar2 = prompt.KeyChar;
449-
var idx2 = (int) Char.GetNumericValue(keyChar2);
450-
451-
// var val = rm.Grid.Rows[choice2i][0];
452-
// var val2 = new Text(val.ToString(), style: new Style(Color.Yellow));
453-
// Debug.WriteLine($"{val} {val2}");
454-
455-
gr2 = rm.UpdateGrid(idx2, true);
456-
457-
layout[L_LEFT].Update(new Panel(rm.Grid));
458-
layout[L_TOP].Update(new Panel(gr2));
459-
460-
AConsole.Clear();
461-
AConsole.Write(layout);
462-
463-
} while (true);
464-
465-
}
466-
else { }
467-
468-
} while (prompt.Key != ConsoleKey.OemMinus);
469-
470-
return EC_OK;
471-
}
472-
473304
public void Dispose()
474305
{
475306
foreach (var sr in m_results) {

SmartImage.Rdx/SearchCommandSettings.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,6 @@ internal sealed class SearchCommandSettings : CommandSettings
4141

4242
#region
4343

44-
[CommandOption("--interactive")]
45-
[DefaultValue(false)]
46-
[Description("Show interactive UI after search")]
47-
public bool? Interactive { get; internal set; }
48-
49-
[CommandOption("--table-format")]
50-
[DefaultValue(OutputFields.None)]
51-
[Description("[Table] Fields to display")]
52-
public OutputFields TableFormat { get; internal set; }
53-
54-
#endregion
55-
56-
#region
57-
5844
[CommandOption("-f|--output-format")]
5945
[DefaultValue(OutputFileFormat.None)]
6046
[Description("Output file format")]

0 commit comments

Comments
 (0)