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

feat(command): new command: uniq() #453

Merged
merged 17 commits into from
Jul 22, 2016
Merged

feat(command): new command: uniq() #453

merged 17 commits into from
Jul 22, 2016

Conversation

joshi-sh
Copy link
Contributor

The uniq utility removes adjacent identical lines from it's input. I have implemented uniq with support for the -i (ignore case) option.

@ariporad
Copy link
Contributor

@nfischer: What are your thoughts on this? I'm not really sure this needs to be a part of shelljs, this could maybe be a plugin, or just a js lib... It's not really shell specific.

@nfischer nfischer self-assigned this Jun 1, 2016
@nfischer
Copy link
Member

nfischer commented Jun 1, 2016

@ariporad This is part of GNU core-utils (here's the source for that), so it seems pretty shell-specific to me. What do you think?

I think this could be a pretty useful utility for some people.

@DaedalusUsedPerl Could you please update this to fix the lint errors?


var result;

result = shell.uniq();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mark this section with:

//
// Invalids
//

See here as an example.

@nfischer nfischer changed the title Implemented uniq for ShellJS feat(command): new command: uniq() Jun 19, 2016
Available options:

+ `-i`: Ignore differences in case when comparing
+ `-c`: Prefix lines by the number of occurrences
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds a bit ambiguous. Could you reword this?

});
uniqed = uniqed.
//Do we want only duplicated objects?
filter(function(obj){return options.duplicates ? obj.count > 1 : true;}).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you write out callbacks in the form:

filter(function (obj) {
  // Do we want only duplicated objects?
  return options.duplicates ? obj.count > 1 : true;
}).map( // etc ...

@nfischer
Copy link
Member

@joshi-sh I left some comments. Overall, looks pretty thorough! This is something I'd really like to see in ShellJS. Most of the comments are very nitpicky, so I can fix them if you'd like.

@joshi-sh
Copy link
Contributor Author

Your comments are pretty reasonable, actually. I just copied the GNU man pages in lieu of writing docs.

@nfischer
Copy link
Member

nfischer commented Jul 20, 2016

Gonna give this an LGTM. We might want to wait to merge until after shelljs v0.7.1, and then this can be in 0.7.2.

Edit: I originally put v0.8 instead of v0.7

@nfischer
Copy link
Member

LGTM 👍

@nfischer
Copy link
Member

I'll handle merging this once we get a patch release out with some of the fixes we've made since v0.7.0.

@nfischer nfischer merged commit 3367e0c into shelljs:master Jul 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants