function getPathAndDepth
getPathAndDepth(argument: string): { file: string; depth: number; }

The path a command was pointed at, and how deep it was asked to go.

Two answers because the argument holds two things and every path command has to separate them before it can do anything. . for nothing typed, since a path command with no path means here.

import { getPathAndDepth } from './path-argument.ts';

getPathAndDepth('-L 2 lib'); // { file: 'lib', depth: 2 }
getPathAndDepth('lib'); // { file: 'lib', depth: Infinity } — all the way down unless told otherwise
getPathAndDepth(''); // { file: '.', depth: Infinity } — here

Parameters

argument: string

Return Type

{ file: string; depth: number; }

Usage

import { getPathAndDepth } from "lib/commands/repl/path-argument.ts";