Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sindresorhus opened this issue Nov 5, 2018 · 5 comments
Closed

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

sindresorhus opened this issue Nov 5, 2018 · 5 comments
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted
Milestone

Comments

@sindresorhus
Copy link
Owner

sindresorhus commented Nov 5, 2018

Issuehunt badges

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?

picchikevin earned $40.00 by resolving this issue!

@IssueHuntBot
Copy link

@issuehuntfest has funded $40.00 to this issue. See it on IssueHunt

@IssueHuntBot
Copy link

@PicchiKevin has submitted a pull request. See it on IssueHunt

@IssueHuntBot
Copy link

@sindresorhus has rewarded $36.00 to @PicchiKevin. See it on IssueHunt

  • 💰 Total deposit: $40.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $4.00

@issuehunt-oss issuehunt-oss bot added the 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt label May 10, 2019
@revelt
Copy link

revelt commented Dec 9, 2019

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.

@sindresorhus
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted
Projects
None yet
Development

No branches or pull requests

3 participants