Skip to content

Flags with optional values #61

@JuanM04

Description

@JuanM04

Is there a way to have optional flag values? Something like the following:

const arg = require('arg');

const args = arg({
	'--port': Number, // --port <number>
	'--host': String.optional, // --host [string]
});

Given --port 5432 --host localhost it should return { _: [], port: 5432, host: 'localhost' },
given --port 5432 --host it should return something like { _: [], port: 5432, host: true },
and given --port 5432 it should return { _: [], port: 5432 },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions