scripts/net.js
/**
 * Do something with the monitoring subsystem
 *
 * @param {string} host - the host to run against
 * @param {*} args - flags passed in from the command line.
 * @param {import('/scripts/index.js').NS} ns
 */
Do something with the monitoring subsystem
@param {string} host - the host to run against
@param {*} args - flags passed in from the command line.
Do something with the monitoring subsystem @param { string } host - the host to run against @param { * } args - flags passed in from the command line .
async function runServersCommand(host, args, ns) {
    const script_server = '/scripts/net-servers.js';
    ns.tprint(`Running server commands: '${args._}'`);
    if (args.help) {
        let msg = `
        server commands. 
        net server list -  list current purchased servers
        net server prices - show price list
        net server buy [num] size - Buy num servers at a particular size. Default 1
        net server buy corp - Buy a 2 TB server, reserved for corporate scripts
        net server delete server# - delete a server
        net server upgrade [server#] size - upgrade existing purchased server to size`;
        ns.tprint(msg);
    } else {
        let action = 'list';
        if (args._.length > 0) {
            action = args._.shift();
        }
        if (action === 'list') {
            ns.exec(script_server, host, 1, '--list');
        }
        if (['price', 'prices'].includes(action)) {
            ns.exec(script_server, host, 1, '--prices');
        }
        if (action == 'buy') {
            if (args._.length > 0 && args._.length <= 2) {
                let siz = args._.pop();
                let num = args._.pop();
                num = num ?? 1;
                if (siz === 'corp') {
                    ns.exec(script_server, host, 1, '--buy', 11, '--name', corpServerName);
                } else {
                    for (let i = 0; i < num; i++) {
                        ns.exec(script_server, host, 1, '--buy', siz);
                    }
                }
            } else {
                let msg = `Unknown arguments to net server buy: '${args._.join(' ')}' expected net server buy [num] siz`;
                ns.tprint(msg);
            }
        }
        if (action === 'delete') {
            let num = args._.shift();
            ns.exec(script_server, host, 1, '--delete', num);
        }
    }
}
async function runServersCommand ( host , args , ns ) { const script_server = '/scripts/net-servers.js' ; ns . tprint ( ` ${ args . _ } ` ) ; if ( args . help ) { let msg = ` ` ; ns . tprint ( msg ) ; } else { let action = 'list' ; if ( args . _ . length > 0 ) { action = args . _ . shift ( ) ; } if ( action === 'list' ) { ns . exec ( script_server , host , 1 , '--list' ) ; } if ( [ 'price' , 'prices' ] . includes ( action ) ) { ns . exec ( script_server , host , 1 , '--prices' ) ; } if ( action == 'buy' ) { if ( args . _ . length > 0 && args . _ . length <= 2 ) { let siz = args . _ . pop ( ) ; let num = args . _ . pop ( ) ; num = num ?? 1 ; if ( siz === 'corp' ) { ns . exec ( script_server , host , 1 , '--buy' , 11 , '--name' , corpServerName ) ; } else { for ( let i = 0 ; i < num ; i ++ ) { ns . exec ( script_server , host , 1 , '--buy' , siz ) ; } } } else { let msg = ` ${ args . _ . join ( ' ' ) } ` ; ns . tprint ( msg ) ; } } if ( action === 'delete' ) { let num = args . _ . shift ( ) ; ns . exec ( script_server , host , 1 , '--delete' , num ) ; } } }
Do something with the monitoring subsystem
 @param {string} host - the host to run against
 @param {*} args - flags passed in from the command line.
Do something with the monitoring subsystem @param { string } host - the host to run against @param { * } args - flags passed in from the command line .
// There should be one or two more items on the command line. // If it's just one, then that's the size. If there's two it should be number then size // Size 11 is 2TB. Use the corp server name from the top of this file.