sindresorhus/meow

Remove short-flags in `cli.flags` if they're defined as `alias` #102

sindresorhus posted onGitHub

const cli = m({
    argv: ['-c', '-l'],
    flags: {
        coco: {
            alias: 'c'
        },
        loco: {
            alias: 'l'
        }
    }
});

console.log(cli.flags);
//=> { c: true, coco: true, l: true, loco: true }

Since c and l are defined as alias for two other flags, I think we should just exclude the short-flags from the cli.flags output. They just create noise there.

So it would be this instead:

console.log(cli.flags);
//=> { coco: true, loco: true }

Thoughts?


hi all, around 10 meow dependent CLI's of mine were dependent on aliases. I've been using if (cli.flags.z) all over the code for convenience. What was done was done, v6 is out and I had to fix bunch of CLI's but in the future please don't remove issues if they already exist and don't block anything.

posted by revelt over 5 years ago

I've been using if (cli.flags.z) all over the code for convenience.

Convenience for you, but worse readability for anyone else reading your code. The change was done exactly to fix code like yours.

please don't remove issues if they already exist and don't block anything.

I cannot promise that. If something will help people improve their CLIs or code, I'll do it.

posted by sindresorhus over 5 years ago

Fund this Issue

$40.00
Rewarded

Rewarded pull request

Recent activities

picchikevin was rewarded by sindresorhus for sindresorhus/meow# 102
about 6 years ago
picchikevin submitted an output to  sindresorhus/ meow# 102
over 6 years ago