bitburner/scripts/update.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-02-10 12:10:26 -05:00
import {ArgParser} from './scripts/lib/arg-parser';
2022-02-04 17:17:13 -05:00
/**
* Automatically download all the scripts in the repository.
*/
2022-02-04 11:49:05 -05:00
export async function main(ns) {
2022-02-10 12:10:26 -05:00
// Initilize script arguments
const argParser = new ArgParser({
desc: 'Automatically update scripts from the repository using wget.',
examples: [
'run update.js',
'run update.js --help',
],
args: [
{key: 'help', alias: 'h', optional: true, desc: 'Display help message'},
]
});
const args = argParser.parse(ns.args);
// Check arguments
if(args['help']) return ns.tprint(argParser.help());
// Setup
2022-02-09 22:25:22 -05:00
const src = 'https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/';
const dist = '/scripts/';
const fileList = [
2022-02-04 17:17:13 -05:00
'auto-pwn.js',
'bruteforce.js',
'crawler.js',
'miner.js',
'node-manager.js',
'update.js'
2022-02-04 11:49:05 -05:00
];
2022-02-04 17:17:13 -05:00
// Download each file
2022-02-04 19:13:35 -05:00
ns.tprint("Downloading scripts:");
2022-02-09 22:25:22 -05:00
for(const file of fileList) {
2022-02-04 18:48:08 -05:00
await ns.sleep(500);
2022-02-09 22:25:22 -05:00
await ns.wget(`${src}${file}`, `${dist}${file}`);
const speed = ~~((Math.random() * 200) + 100) / 10;
ns.tprint(`${file} ${file.length <= 10 ? '\t' : ''}\t [==================>] 100% \t (${speed} MB/s)`);
2022-02-04 11:49:05 -05:00
}
2022-02-04 17:17:13 -05:00
ns.tprint('Done!');
2022-02-04 11:49:05 -05:00
}