fixed column behavior in qdls

This commit is contained in:
Valerie Wolfe 2024-06-10 13:05:12 -04:00
parent 1b42869e3f
commit 763ccb3291

View file

@ -1,5 +1,4 @@

using Qdls;
using Qdls;
// collect args and consume flags
List<string> arguments = args.ToList();
@ -25,10 +24,10 @@ foreach(var arg in arguments) {
// state vars
var buffer = "";
var longest = children.OrderByDescending(s => Path.GetFileName(s).Length).First().Length;
var longest = Path.GetFileName(children.OrderByDescending(s => s.Length).First()).Length;
var columns = Console.WindowWidth / (longest + 2);
var multiline = columns < args.Length;
var position = -1;
var multiline = columns < children.Count();
var position = 0;
// print names if more than one target
if(args.Length > 1)
@ -46,13 +45,13 @@ foreach(var arg in arguments) {
buffer += Format.Directory;
// if we pass max width, write buffer and clear
if( multiline && (++position > columns) ) {
position = -1;
Console.WriteLine(buffer);
if( (++position > columns) && multiline ) {
position = 1;
Console.WriteLine(buffer.TrimEnd());
buffer = "";
}
if(multiline)
buffer += $"{name}{Format.Reset}".PadRight(longest) + " ";
buffer += $"{name}{Format.Reset}".PadRight(longest + 4);
else
buffer += $"{name}{Format.Reset} ";