How to use the out function from yargs
Find comprehensive JavaScript yargs.out code examples handpicked from public code repositorys.
yargs.out is a method used to customize where yargs output is displayed.
GitHub: iTwin/itwinjs-core
20 21 22 23 24 25 26 27 28 29 30 31
process.on("unhandledRejection", err => { throw err; }); const source = (argv.source === undefined) ? paths.appSrc : argv.source; const out = (argv.out === undefined) ? paths.appDocs : argv.out; const json = (argv.json === undefined) ? paths.appJsonDocs : argv.json; const baseUrlOptions = (argv.baseUrl === undefined) ? [] : ["--baseUrl", argv.baseUrl]; const includeOptions = (argv.includes === undefined) ? [] : ["--includes", argv.includes];
193
513
0
+ 4 other calls in file
GitHub: overte-org/overte
32 33 34 35 36 37 38 39 40 41
} } // check if we were passed a custom out directory, pass it along if so if (argv.out) { options.out = argv.out } // call the packager to produce the executable packager(options)
31
63
3
How does yargs.out work?
yargs.out is a property in the Yargs module that sets the output stream for logs and errors. It is used to redirect the output to a different stream than the default one (process.stdout). By default, it is set to process.stdout, but it can be changed to any other Writable stream.
Ai Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
const fs = require("fs"); const yargs = require("yargs"); const logs = fs.createWriteStream("logs.txt"); yargs .usage("Usage: $0 [options]") .command( "start", "Start the server", () => {}, (argv) => { yargs.out(logs); // use logs file as output stream console.log("Server started!"); } ) .parse();
In this example, yargs.out(logs) sets the output stream to the logs file for the start command, so any logs generated by Yargs or the application will be written to this file instead of the default output stream (usually the console).
yargs.argv is the most popular function in yargs (1012 examples)