More documentation
This commit is contained in:
		@@ -41,6 +41,8 @@ It's recommended you run this in combination with `auto-pwn.js` to gain root & r
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### [node-manager.js](./scripts/node-manager.js)
 | 
					### [node-manager.js](./scripts/node-manager.js)
 | 
				
			||||||
**RAM:** 5.70 GB
 | 
					**RAM:** 5.70 GB
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Buy, upgrade & manage Hacknet nodes automatically.
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
[home ~/]> run scripts/node-manager.js --help
 | 
					[home ~/]> run scripts/node-manager.js --help
 | 
				
			||||||
Running script with 1 thread(s), pid 128 and args: ["--help"].
 | 
					Running script with 1 thread(s), pid 128 and args: ["--help"].
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,19 @@
 | 
				
			|||||||
export class ArgParser {
 | 
					export class ArgParser {
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Create a unix-like argument parser to extract flags from the argument list. Can also create help messages.
 | 
				
			||||||
 | 
						 * @param opts - {examples: string[], arguments: {key: string, alias: string, type: string, optional: boolean, desc: string}[], desc: string}
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	constructor(opts) {
 | 
						constructor(opts) {
 | 
				
			||||||
		this.examples = opts.examples ?? [];
 | 
							this.examples = opts.examples ?? [];
 | 
				
			||||||
		this.arguments = opts.args ?? [];
 | 
							this.arguments = opts.args ?? [];
 | 
				
			||||||
		this.description = opts.desc;
 | 
							this.description = opts.desc;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Parse the list for arguments & create a dictionary.
 | 
				
			||||||
 | 
						 * @param args {any[]} - Array of arguments
 | 
				
			||||||
 | 
						 * @returns Dictionary of matched flags + unmatched args under 'extra'
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	parse(args) {
 | 
						parse(args) {
 | 
				
			||||||
		const req = this.arguments.filter(a => !a.optional);
 | 
							const req = this.arguments.filter(a => !a.optional);
 | 
				
			||||||
		const queue = [...args];
 | 
							const queue = [...args];
 | 
				
			||||||
@@ -29,6 +38,10 @@ export class ArgParser {
 | 
				
			|||||||
		return parsed;
 | 
							return parsed;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Create a help message of the expected paramters & usage.
 | 
				
			||||||
 | 
						 * @param msg {String} - Optional message to display with help
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	help(msg) {
 | 
						help(msg) {
 | 
				
			||||||
		let message = '\n\n';
 | 
							let message = '\n\n';
 | 
				
			||||||
		message += msg ? msg : this.description;
 | 
							message += msg ? msg : this.description;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ export async function main(ns) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Print header with logs
 | 
						 * Print header with logs
 | 
				
			||||||
	 * message - message to append to logs
 | 
						 * @param message - message to append to logs
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	function log(message) {
 | 
						function log(message) {
 | 
				
			||||||
		ns.clearLog();
 | 
							ns.clearLog();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user