spotify-cli / parse
parse
Utility parsers for CLI argument values.
Functions
ensureTrackUri()
ensureTrackUri(
id):string
Defined in: src/parse.ts:53
Ensures a string is a full Spotify track URI. If the input already starts with spotify:, it is returned as-is. Otherwise it is treated as a bare track ID and prefixed with spotify:track:.
Parameters
id
string
Returns
string
optionalIntFlag()
optionalIntFlag(
flags,name):number|undefined
Defined in: src/parse.ts:32
Reads an optional integer flag from a flags record.
Returns undefined when the flag is absent or empty, otherwise delegates to parseIntFlag.
Parameters
flags
Record<string, string>
The parsed flags record from CLI args.
name
string
The flag name (without -- prefix).
Returns
number | undefined
The parsed integer, or undefined if not provided.
parseIntFlag()
parseIntFlag(
value,name):number
Defined in: src/parse.ts:16
Parses a string as a base-10 integer or throws an argsError.
Parameters
value
string
The raw string value to parse.
name
string
Display name used in the error message (e.g. "--limit").
Returns
number
The parsed integer.
Throws
SpotifyCliError if the value is not a valid integer.
requireIds()
requireIds(
positional,usage):string[]
Defined in: src/parse.ts:57
Parameters
positional
string[]
usage
string
Returns
string[]