question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
reveltcommented, 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.

0reactions
sindresorhuscommented, Dec 12, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing flags to a command inside an alias - linux - Super User
I have created an alias for ls in order to let it print out a format that I like. I have defined the...
Read more >
Clarify description of --alias flag for deploy command #1984
We got some docs-related feedback about the --alias flag for the deploy command. The alias flag was renamed to from the branch flag,...
Read more >
Linux alias Command: How to Use It With Examples
In this tutorial, learn how to create, view, and remove temporary and permanent command shortcuts in Linux using the alias command.
Read more >
Command-line syntax overview for System.CommandLine
An introduction to the command-line syntax that the System.CommandLine library recognizes by default. Mentions exceptions where syntax in ...
Read more >
Using Cobra and Go to Create Command Line Utilities - Linode
Cobra is a popular Go package that lets you develop command line ... for command line flags; A command line utility with command...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found