| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dbb8f37 commit 43092eb
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,6 +69,7 @@ function getArgDescription(type) { | |||
| 69 | 69 | ||
| 70 | 70 | function format({ options, aliases = new Map(), firstColumn, secondColumn }) { | |
| 71 | 71 | let text = ''; | |
| 72 | + let maxFirstColumnUsed = 0; | ||
| 72 | 73 | ||
| 73 | 74 | for (const [ | |
| 74 | 75 | name, { helpText, type, value } | |
@@ -106,6 +107,7 @@ function format({ options, aliases = new Map(), firstColumn, secondColumn }) { | |||
| 106 | 107 | } | |
| 107 | 108 | ||
| 108 | 109 | text += displayName; | |
| 110 | + maxFirstColumnUsed = Math.max(maxFirstColumnUsed, displayName.length); | ||
| 109 | 111 | if (displayName.length >= firstColumn) | |
| 110 | 112 | text += '\n' + ' '.repeat(firstColumn); | |
| 111 | 113 | else | |
@@ -115,16 +117,26 @@ function format({ options, aliases = new Map(), firstColumn, secondColumn }) { | |||
| 115 | 117 | firstColumn).trimLeft() + '\n'; | |
| 116 | 118 | } | |
| 117 | 119 | ||
| 120 | + if (maxFirstColumnUsed < firstColumn - 4) { | ||
| 121 | + // If we have more than 4 blank gap spaces, reduce first column width. | ||
| 122 | + return format({ | ||
| 123 | + options, | ||
| 124 | + aliases, | ||
| 125 | + firstColumn: maxFirstColumnUsed + 2, | ||
| 126 | + secondColumn | ||
| 127 | + }); | ||
| 128 | + } | ||
| 129 | + | ||
| 118 | 130 | return text; | |
| 119 | 131 | } | |
| 120 | 132 | ||
| 121 | 133 | function print(stream) { | |
| 122 | 134 | const { options, aliases } = getOptions(); | |
| 123 | 135 | ||
| 124 | - // TODO(addaleax): Allow a bit of expansion depending on `stream.columns` | ||
| 125 | - // if it is set. | ||
| 126 | - const firstColumn = 28; | ||
| 127 | - const secondColumn = 40; | ||
| 136 | + // Use 75 % of the available width, and at least 70 characters. | ||
| 137 | + const width = Math.max(70, (stream.columns || 0) * 0.75); | ||
| 138 | + const firstColumn = Math.floor(width * 0.4); | ||
| 139 | + const secondColumn = Math.floor(width * 0.57); | ||
| 128 | 140 | ||
| 129 | 141 | options.set('-', { helpText: 'script read from stdin (default; ' + | |
| 130 | 142 | 'interactive mode if a tty)' }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments