Skip to content

Can we add aliases list and rm for ls and remove? #1628

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

Closed
alanhogan opened this issue Nov 3, 2016 · 16 comments
Closed

Can we add aliases list and rm for ls and remove? #1628

alanhogan opened this issue Nov 3, 2016 · 16 comments

Comments

@alanhogan
Copy link

alanhogan commented Nov 3, 2016

Do you want to request a feature or report a bug?
Feature

What is the current behavior?

$ yarn list
yarn list v0.16.1
error Did you mean `yarn ls`?
$ yarn rm somepkg
yarn rm v0.16.1
error Did you mean `yarn remove`?

If the current behavior is a bug, please provide the steps to reproduce.
Not a bug per se, but it feels schizo to ask users to use the unix verb in one instance and the human verb in the next.

What is the expected behavior?
Consistency, or better yet, flexibility! 👍

Please mention your node.js, yarn and operating system version.
node 6.9.1 / yarn 0.16.1 / macOS 10.12.1

<3

@mguida22
Copy link

mguida22 commented Nov 3, 2016

I looked into fixing this, but it appears that aliases are intentionally used as recommendations and not meant to actually execute?

from src/cli/index.js#L122-L130

if (commandName && typeof aliases[commandName] === 'string') {
  const alias = aliases[commandName];
  command = {
    run(config: Config, reporter: ConsoleReporter | JSONReporter): Promise<void> {
      throw new MessageError(`Did you mean \`yarn ${alias}\`?`);
    },
  };
}

Upon further digging through the history, it was changed to an error in commit ef0f9f1 which is part of this PR #439. I'm not sure the reasoning for the changes, but I imagine it wasn't changed by accident. Perhaps @kittens has more insight?

Hope this helps some 😄

@sebmck
Copy link
Contributor

sebmck commented Nov 3, 2016

We don't want aliases since it's confusing to have multiple commands that do the same thing. We can either:

  • Change ls to list.
  • Change remove to rm.
  • Do nothing and ignore the inconsistency.

@mguida22
Copy link

mguida22 commented Nov 3, 2016

Since all of the other cli commands look to be complete words, changing ls to list makes the most sense to me. If that sounds good I can make a PR with the changes.

@alanhogan
Copy link
Author

alanhogan commented Nov 3, 2016

That sounds reasonable to me, Michael.

I’m not sure I understand how aliases are confusing, Sebastian, but I am open to that possibly being true. I imagine a well-designed "yarn help" would designate common aliases as such, though.

@BLamy
Copy link

BLamy commented Nov 17, 2016

Would really like to see this. TBH I don't agree that it's confusing, I'd venture to say most developers working with yarn are familiar with the concept of aliases. Seems like the usability equivalent of a microoptimization to me,

I use npm i over npm install all the time, Googling for what does npm i mean yields nothing that implies that it has caused confusion.
It's kind of annoying to type rm out of habit only to be kicked out and have to type it again.

@torifat
Copy link
Member

torifat commented Nov 17, 2016

I would prefer something like git alias option over providing a lot of built in aliases.

And, currently I have a alias y=yarn in my env. So, for me y add is ok. And, if I wish I can go ham like alias ya="yarn add" alias yr="yarn remove"

@danielmcgraw
Copy link
Contributor

danielmcgraw commented Nov 18, 2016

PR: #1940

Renamed ls to list, updated the aliases files so ls points to list.

@busches
Copy link
Contributor

busches commented Nov 23, 2016

What about the subcommand options? All of them are ls or rm unless you're doing global then it's list and remove, is that ok?

@arteezy
Copy link

arteezy commented Dec 5, 2016

Inconsistency is now through the roof after #1940 merged in v0.18 release:

$ yarn ls
yarn ls v0.18.0
error Did you mean `yarn list`?

$ yarn global list
yarn global v0.18.0
error Invalid subcommand. Try "add, bin, ls, remove, upgrade"

$ yarn config ls
yarn config v0.18.0
error Invalid subcommand. Try "set, get, delete, list"

$ yarn cache list
yarn cache v0.18.0
error Invalid subcommand. Try "ls, dir, clean"

@iest
Copy link

iest commented Dec 7, 2016

Aside from the inconsistency, isn't renaming commands a "breaking" API change?
We have dev scripts on some projects that rely on yarn commands that we now have to change, even though 0.17.0 to 0.18.0 is a minor change.

Also not that my opinion matters, but I don't see the issue with having multiple commands do the same thing. It's a very common behaviour across all CLI tools after all.

Even throwing a warning and just running the command anyway would be more helpful than just saying "did you mean X?"

@ljharb
Copy link

ljharb commented Dec 7, 2016

@iest in semver prior to 1.0, a minor version bump is for breaking changes - ie, 0.17 to 0.18 is indeed a breaking change.

@iest
Copy link

iest commented Dec 7, 2016

Fair enough, ignore me.

@vogler
Copy link

vogler commented Jan 17, 2017

❯ yarn ls
yarn ls v0.19.1
error Did you mean `yarn list`?
info Visit https://yarnpkg.com/en/docs/cli/list for documentation about this command.

-> Page Not Found

https://yarnpkg.com/en/docs/cli/ls works 😱

@gaboesquivel
Copy link

gaboesquivel commented Feb 26, 2017

I'd personally prefer matching with Unix commands: ls, rm. For consistency across tooling.
Adding aliases would be nice. It's also shorter, less chars to type.

I know you can always alias on your bash profile, I usually do. But there are servers and containers too.

@cooljl31
Copy link

cooljl31 commented May 8, 2017

node -v
v6.6.0
yarn ls v0.23.2
error Did you mean yarn list?
info Visit https://yarnpkg.com/en/docs/cli/list for documentation about this command.

@gsklee
Copy link
Contributor

gsklee commented May 22, 2017

@bestander close

The consensus seems to be that we're removing aliases from Yarn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests