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

Add a list command #159

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Conversation

sap1enza
Copy link
Contributor

@sap1enza sap1enza commented Oct 3, 2023

WHAT

list all, common, with or without ref, extended or not.

ISSUE

FIX #155

@sap1enza sap1enza changed the title create list command Add a list command Oct 3, 2023
@sonarcloud
Copy link

sonarcloud bot commented Oct 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

# HashIdentifier.list
# # => ["CRC-16", "CRC-16-CCITT", "FCS-16", "Adler-32", "CRC-32B", "FCS-32"]
def list
(PROTOTYPES.flat_map { |d| d["modes"].map { |m| m["name"]}} + COMMONS).uniq
Copy link
Owner

Choose a reason for hiding this comment

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

COMMONS is a subset of PROTOTYPES hash types so it should not add more types. In practice there is a slight difference because at some point PROTOTYPES was updated while COMMONS was not, so I'll make sure to make the changes on it. So commons can be removed.

Copy link
Owner

Choose a reason for hiding this comment

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

Also I added a .sort

# # => ["CRC-16", "CRC-16-CCITT", "FCS-16", "Adler-32", "CRC-32B", "FCS-32"]
def list
(PROTOTYPES.flat_map { |d| d["modes"].map { |m| m["name"]}} + COMMONS).uniq
end
Copy link
Owner

Choose a reason for hiding this comment

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

I checked the linting rules with bundle exec rubocop and had to make some changes. Some dev commands are displayed here: https://noraj.github.io/haiti/#/pages/publishing

@@ -15,6 +15,7 @@ Usage:

Commands:
samples Display hash samples for the given type
list Display array list of available types
Copy link
Owner

Choose a reason for hiding this comment

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

The change in lib/haiti.rb actually added the feature in the lib but some changes have to be made in bin/haiti too. In order to add the command to the CLI.

@@ -15,6 +15,7 @@ Usage:

Copy link
Owner

Choose a reason for hiding this comment

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

LIke them samples command, the list one need to be added to docopt else it won't be parsed.

# @example
# HashIdentifier.list
# # => ["CRC-16", "CRC-16-CCITT", "FCS-16", "Adler-32", "CRC-32B", "FCS-32"]
def list
Copy link
Owner

Choose a reason for hiding this comment

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

My bad the description list all, common, with or without ref, extended or not. was not clear enough, but I expected to have parameters to filter. Eg. displaying the extended hash types or only the common ones, etc. all the same options as for the default identifying method.

noraj added a commit that referenced this pull request Oct 4, 2023
@noraj noraj merged commit 01357c1 into noraj:master Oct 4, 2023
2 checks passed
@noraj
Copy link
Owner

noraj commented Oct 4, 2023

That was only 10% of the feature, I completed the rest:

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

Successfully merging this pull request may close these issues.

Add a list command
2 participants