mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
ls-changes
This commit is contained in:
parent
d347bf568e
commit
9a9d2e1f81
@ -1702,10 +1702,14 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display all programs and scripts
|
// Display all programs and scripts
|
||||||
let allFiles = [];
|
const allPrograms = [];
|
||||||
let folders = [];
|
const allScripts = [];
|
||||||
|
const allTextFiles = [];
|
||||||
|
const allContracts = [];
|
||||||
|
const allMessages = [];
|
||||||
|
const folders = [];
|
||||||
|
|
||||||
function handleFn(fn) {
|
function handleFn(fn, dest) {
|
||||||
let parsedFn = fn;
|
let parsedFn = fn;
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
if (!fn.startsWith(prefix)) {
|
if (!fn.startsWith(prefix)) {
|
||||||
@ -1734,29 +1738,53 @@ let Terminal = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
allFiles.push(parsedFn);
|
dest.push(parsedFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all of the programs and scripts on the machine into one temporary array
|
// Get all of the programs and scripts on the machine into one temporary array
|
||||||
const s = Player.getCurrentServer();
|
const s = Player.getCurrentServer();
|
||||||
for (const program of s.programs) handleFn(program);
|
for (const program of s.programs) handleFn(program, allPrograms);
|
||||||
for (const script of s.scripts) handleFn(script.filename);
|
for (const script of s.scripts) handleFn(script.filename, allScripts);
|
||||||
for (const txt of s.textFiles) handleFn(txt.fn);
|
for (const txt of s.textFiles) handleFn(txt.fn, allTextFiles);
|
||||||
for (const contract of s.contracts) handleFn(contract.fn);
|
for (const contract of s.contracts) handleFn(contract.fn, allContracts);
|
||||||
for (const msgOrLit of s.messages) (msgOrLit instanceof Message) ? handleFn(msgOrLit.filename) : handleFn(msgOrLit);
|
for (const msgOrLit of s.messages) (msgOrLit instanceof Message) ? handleFn(msgOrLit.filename, allMessages) : handleFn(msgOrLit, allMessages);
|
||||||
|
|
||||||
// Sort the files/folders alphabetically then print each
|
// Sort the files/folders alphabetically then print each
|
||||||
allFiles.sort();
|
allPrograms.sort();
|
||||||
|
allScripts.sort();
|
||||||
|
allTextFiles.sort();
|
||||||
|
allContracts.sort();
|
||||||
|
allMessages.sort();
|
||||||
folders.sort();
|
folders.sort();
|
||||||
|
|
||||||
const config = { color: "#0000FF" };
|
function postSegments(segments, config) {
|
||||||
for (const dir of folders) {
|
const maxLength = Math.max(...segments.map(s => s.length))+1;
|
||||||
postContent(dir, config);
|
const filesPerRow = Math.floor(80 / maxLength);
|
||||||
|
for(let i = 0; i < segments.length; i++) {
|
||||||
|
let row = '';
|
||||||
|
for(let col = 0; col < filesPerRow; col++) {
|
||||||
|
if(!(i < segments.length)) break;
|
||||||
|
row += segments[i];
|
||||||
|
row += " ".repeat((maxLength * (col+1)) - row.length);
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
postContent(row, config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const file of allFiles) {
|
|
||||||
postContent(file);
|
const config = { color: "#0000FF" };
|
||||||
}
|
postSegments(folders, config);
|
||||||
|
postElement(<br />);
|
||||||
|
postSegments(allMessages);
|
||||||
|
postElement(<br />);
|
||||||
|
postSegments(allTextFiles);
|
||||||
|
postElement(<br />);
|
||||||
|
postSegments(allPrograms);
|
||||||
|
postElement(<br />);
|
||||||
|
postSegments(allContracts);
|
||||||
|
postElement(<br />);
|
||||||
|
postSegments(allScripts);
|
||||||
},
|
},
|
||||||
|
|
||||||
executeMemCommand: function(commandArray) {
|
executeMemCommand: function(commandArray) {
|
||||||
|
Loading…
Reference in New Issue
Block a user