Solution: lb_ls

Node.js·2 min read·Apr 17, 2025

Here is the commented solution for this project.

Set up the project

Create a file named lb_ls.js.

$ touch lb_ls.js

Implement the command-line parser

The objective of this part is to implement a parser for command-line flags and positional arguments.

Import the parseArgs() function exported by the core Node.js node:util module

lb_ls.js
const { parseArgs } = require('node:util');

Use the parseArgs() function to define the -r (short for --reverse), -A (short for --all), and -R (short for --recursive) boolean command-line flags and allow for positional arguments.

lb_ls.js
const { parseArgs } = require('node:util');const { values, positionals } = parseArgs({  options: {    'reverse': {      type: 'boolean',

Unlock the full program 🚀

Pay once, own it forever.

149

30-day money-back guarantee

  • 13 modules
  • 113 lessons with full-code examples
  • 29 projects with commented solutions
  • All future lesson and project updates
  • Lifetime access

By submitting this form, you agree to the Terms & Conditions and Privacy Policy.