Commit 6aa053e

bryfry <bryon@fryer.io>
2025-09-18 08:14:20
better table sizes
1 parent 0af402d
Changed files (3)
cmd/files.go
@@ -125,17 +125,17 @@ func runFilesList(cmd *cobra.Command, args []string) error {
 		},
 	})
 
-	// Define columns with priorities (1=highest, higher numbers can be dropped)
+	// Define columns with priorities for responsive display
 	columns := []ColumnInfo{
-		{Header: "UUID", Number: 1, MinWidth: 36, MaxWidth: 36, Priority: 1}, // Always show full UUID
-		{Header: "TYPE", Number: 2, MinWidth: 6, MaxWidth: 8, Priority: 2},   // High priority
-		{Header: "FILENAME", Number: 3, MinWidth: 8, MaxWidth: 16, Priority: 3}, // Important
-		{Header: "REMOTE PATH", Number: 4, MinWidth: 10, MaxWidth: 20, Priority: 7}, // Lower priority
-		{Header: "HOST", Number: 5, MinWidth: 6, MaxWidth: 10, Priority: 5},
-		{Header: "SIZE", Number: 6, MinWidth: 5, MaxWidth: 8, Priority: 8},   // Can drop
-		{Header: "COMPLETE", Number: 7, MinWidth: 4, MaxWidth: 6, Priority: 4}, // Important
-		{Header: "TASK", Number: 8, MinWidth: 4, MaxWidth: 6, Priority: 9},   // Can drop
-		{Header: "TIMESTAMP", Number: 9, MinWidth: 8, MaxWidth: 12, Priority: 6}, // Can drop
+		{Header: "UUID", Number: 1, MinWidth: 8, MaxWidth: 36, Priority: 5},        // Can drop on small screens
+		{Header: "TYPE", Number: 2, MinWidth: 6, MaxWidth: 10, Priority: 3},        // Important
+		{Header: "FILENAME", Number: 3, MinWidth: 10, MaxWidth: 30, Priority: 1},   // Never drop - most important
+		{Header: "REMOTE PATH", Number: 4, MinWidth: 12, MaxWidth: 40, Priority: 6}, // First to drop
+		{Header: "HOST", Number: 5, MinWidth: 8, MaxWidth: 20, Priority: 4},        // Medium priority
+		{Header: "SIZE", Number: 6, MinWidth: 6, MaxWidth: 10, Priority: 3},        // Important
+		{Header: "COMPLETE", Number: 7, MinWidth: 6, MaxWidth: 8, Priority: 2},     // High priority
+		{Header: "TASK", Number: 8, MinWidth: 4, MaxWidth: 8, Priority: 5},         // Can drop
+		{Header: "TIMESTAMP", Number: 9, MinWidth: 12, MaxWidth: 16, Priority: 7},  // First to drop
 	}
 
 	// Configure table for current terminal width
@@ -176,9 +176,9 @@ func runFilesList(cmd *cobra.Command, args []string) error {
 			fileType = "upload"
 		}
 
-		// Prepare all column data
+		// Prepare all column data in the order defined by columns
 		allData := []interface{}{
-			file.AgentFileID, // Show full UUID
+			file.AgentFileID,
 			fileType,
 			filename,
 			remotePath,
cmd/root.go
@@ -89,12 +89,25 @@ type DynamicTable struct {
 func configureTableForTerminal(t table.Writer, columns []ColumnInfo) *DynamicTable {
 	termWidth := getTerminalWidth()
 
-	// Reserve space for table library's internal padding and margins
-	availableWidth := termWidth - 4 // -4 to account for table library overhead
+	// First pass: estimate how many columns we can fit
+	// The table library adds 2 spaces around each column's content (1 before, 1 after)
+	// Plus we need some margin for the table structure itself
+	estimatedColumns := len(columns)
+	estimatedPadding := (estimatedColumns * 2) + 2 // 2 per column + 2 for margins
+	availableWidth := termWidth - estimatedPadding
 
 	// Filter columns that can fit and distribute width
 	visibleColumns, columnWidths := distributeColumnWidths(columns, availableWidth)
 
+	// Recalculate with actual column count
+	actualPadding := (len(visibleColumns) * 2) + 2
+	availableWidth = termWidth - actualPadding
+
+	// Re-distribute if needed with correct padding
+	if actualPadding < estimatedPadding {
+		visibleColumns, columnWidths = distributeColumnWidths(columns, availableWidth)
+	}
+
 	// Create headers and column configs for visible columns
 	var headers []interface{}
 	var configs []table.ColumnConfig
@@ -152,8 +165,10 @@ func distributeColumnWidths(columns []ColumnInfo, availableWidth int) ([]ColumnI
 
 	for _, col := range sortedCols {
 		// Check if adding this column would exceed available width
-		// Add 1 space per column for minimal padding
-		newTotal := totalMinWidth + col.MinWidth + 1
+		newTotal := totalMinWidth + col.MinWidth
+		if len(visibleColumns) > 0 {
+			newTotal++ // Add 1 space between columns
+		}
 		if newTotal <= availableWidth {
 			visibleColumns = append(visibleColumns, col)
 			totalMinWidth = newTotal
@@ -166,7 +181,7 @@ func distributeColumnWidths(columns []ColumnInfo, availableWidth int) ([]ColumnI
 	// Ensure we have at least one column (highest priority)
 	if len(visibleColumns) == 0 && len(sortedCols) > 0 {
 		visibleColumns = append(visibleColumns, sortedCols[0])
-		totalMinWidth = sortedCols[0].MinWidth + 1 // Include minimal padding
+		totalMinWidth = sortedCols[0].MinWidth
 	}
 
 	// Step 2: Distribute available width across visible columns
TODO.md
@@ -1,7 +1,15 @@
+
+- grep --delete - flag that deletes the tasking from the server that match the grep - require confirmation
+
+
 - forge payloads - equivalency with execute_assembly and inline_assembly
 - MYTHIC_API_INSECURE= boolean --insecure flag - and invert default = false
 - update output table formats to respect terminal width
 - invert cobra-cli nto functions (no global vars)
+
+
+
+
 - โœ… grep --raw - only diplay of all matching items raw output follow grep -R style single-line file dilimeters in the output
 - โœ… use per-server cache dirs
 - โœ… make sure raw output has a newline at the end