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

topfew 1.0.0 (new formula) #170968

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

topfew 1.0.0 (new formula) #170968

wants to merge 4 commits into from

Conversation

timbray
Copy link

@timbray timbray commented May 6, 2024

Topfew is a dependency-free Golang command-line utility. The command is "tf". If you entered

tf -f 7

that would do the equivalent of

awk '{print $7}' | sort | uniq -c | sort -nr | head

i.e., find and print out the ten most common values of field number 7 in records read from stdin. It has lots of options to select fields. It is significantly faster than the shell pipeline above and, in the case where it's applied to a named file as opposed to stdin, much much faster because it divides the file into segments and process them in multiple threads.

The github repo has decent README.md and CONTRIBUTING.md files and I'm working on an INSTALLING.md which, if this is accepted, would include "brew install topfew".

Its development is rather fully described in a series of blog posts. This 1.0.0 release is discussed in Topfew 1.0.

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

Topfew is a dependency-free Golang command-line utility. The command is "tf".
If you entered

tf -f 7

that would do the equivalent of

awk '{print $7}' | sort | uniq -c | sort -nr | head

i.e., find and print out the ten most common values of field number 7
in records read from stdin.  It has lots of options to select fields.
It is significantly faster than the shell pipeline above and, in the
case where it's applied to a named file as opposed to stdin, much much
faster because it divides the file into segments and process them
in multiple threads.

The github repo is https://github.com/timbray/topfew
It has decent README.md and CONTRIBUTING.md files and
I'm working on an INSTALLING.md which, if this is accepted, would
include "brew install topfew".

Its development is rather fully described in a series of blog posts,
see https://www.google.com/search?as_q=topfew&as_sitesearch=tbray.org
This 1.0.0 release is discussed in https://www.tbray.org/ongoing/When/202x/2024/04/12/Topfew-release
@github-actions github-actions bot added go Go use is a significant feature of the PR or issue new formula PR adds a new formula to Homebrew/homebrew-core labels May 6, 2024
Copy link
Contributor

github-actions bot commented May 6, 2024

Thanks for contributing to Homebrew! 🎉 It looks like you're having trouble with a CI failure. See our contribution guide for help. You may be most interested in the section on dealing with CI failures. You can find the CI logs in the Checks tab of your pull request.

Signed-off-by: Tim Bray <tbray@textuality.com>
@github-actions github-actions bot added the autosquash Automatically squash pull request commits according to Homebrew style. label May 6, 2024
depends_on "go" => :build

def install
system "go", "build", "-trimpath", "-o", "topfew"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
system "go", "build", "-trimpath", "-o", "topfew"
system "go", "build", "-trimpath", *std_go_args(out: bin/"tf")

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

It's probably output: then

end

test do
assert_match "1 bar", shell_output("echo 'foo bar' | #{bin}/tf -f 2")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert_match "1 bar", shell_output("echo 'foo bar' | #{bin}/tf -f 2")
assert_match "1 bar", pipe_output("#{bin}/tf -f 2", "foo bar")

Copy link
Author

Choose a reason for hiding this comment

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

The problem was that the build step was failing, it didn't like *std_go_args(out: bin/"tf"). Having fixed that, I discovered that pipe_output("#{bin}/tf -f 2", "foo bar") also doesn't work, while my original formulation, assert_match "1 bar", shell_output("echo 'foo bar' | #{bin}/tf -f 2") does work. Are we perhaps using a different version of brew?

@chenrui333
Copy link
Member

I might think the binary might need a better name than tf, as tf is popular alias to terraform.

Signed-off-by: Tim Bray <tbray@textuality.com>
@timbray
Copy link
Author

timbray commented May 7, 2024

Pardon the sloppy follow-up commit messages. I'm happy to let brew's CI go ahead and auto-squash, I haven't done a rebase/squash in like a year and would be happy to avoid re-learning that stuff.

@timbray
Copy link
Author

timbray commented May 7, 2024

I might think the binary might need a better name than tf, as tf is popular alias to terraform.

Hmm, maybe? Terraform is about to become known as OpenTofu… Maybe "tfw". Maybe produce two binaries, "topfew" and "tf"? I don't have strong opinions on this.

@chenrui333
Copy link
Member

I might think the binary might need a better name than tf, as tf is popular alias to terraform.

Hmm, maybe? Terraform is about to become known as OpenTofu… Maybe "tfw". Maybe produce two binaries, "topfew" and "tf"? I don't have strong opinions on this.

yeah, tf could be used for both (it would mostly ease the conflicts_with setup)

@timbray
Copy link
Author

timbray commented May 7, 2024

Hmm, maybe? Terraform is about to become known as OpenTofu… Maybe "tfw". Maybe produce two binaries, "topfew" and "tf"? I don't have strong opinions on this.

yeah, tf could be used for both (it would mostly ease the conflicts_with setup)

Strictly, there's no need for conflicts_with, I looked at the Terraform formula and everything is just "terraform". And seriously, there is the OpenTofu issue. So I'd prefer to leave it as tf and if that really isn't acceptable, stick with just topfew.

@chenrui333
Copy link
Member

Hmm, maybe? Terraform is about to become known as OpenTofu… Maybe "tfw". Maybe produce two binaries, "topfew" and "tf"? I don't have strong opinions on this.

yeah, tf could be used for both (it would mostly ease the conflicts_with setup)

Strictly, there's no need for conflicts_with, I looked at the Terraform formula and everything is just "terraform". And seriously, there is the OpenTofu issue. So I'd prefer to leave it as tf and if that really isn't acceptable, stick with just topfew.

if you look at coreutils for gnu drop-in replacements, we did the rename as well, so is true for jruby stuff, I dont think it is that beneficial to introduce the conflicts.

In other words, you probably should consider to do the tap host.

@timbray
Copy link
Author

timbray commented May 8, 2024

Thanks for the input. Unfortunately I'm a newbie here and I'm not sure I understand.

if you look at coreutils for gnu drop-in replacements, we did the rename as well, so is true for jruby stuff, I dont think it is that beneficial to introduce the conflicts.

For coreutils, I guess you mean as described in https://apple.stackexchange.com/questions/69223/how-to-replace-mac-os-x-utilities-with-gnu-core-utilities? In this case you put a "g" prefix but also allow people to use unprefixed form by changing PATH. So you are suggesting that the "topfew" form would be linked but "tf" would still be available via changing PATH? (Sorry if this is a dumb question.)

I don't understand the jruby comment, I have used "brew install jruby" in the past. I have never seen jruby referred to as anything but jruby.

In other words, you probably should consider to do the tap host.

Um, what does "do the tap host" mean? I'm new to Brew.

I would like to say that I'm serious about the status of Terraform, see OpenTofu Announces Fork of Terraform - Terraform is no longer open-source! And it's owned by IBM. I wonder if it's necessary for Brew to make life easier for users of non-OSS IBM product.

@SMillerDev
Copy link
Member

I would like to say that I'm serious about the status of Terraform, see OpenTofu Announces Fork of Terraform - Terraform is no longer open-source! And it's owned by IBM. I wonder if it's necessary for Brew to make life easier for users of non-OSS IBM product.

Terraform, and it's successor in Homebrew OpenTofu, are tf for most people. So if we can avoid the conflict on that by calling the less popular topfew by it's full name, I think that would be preferable.

@timbray
Copy link
Author

timbray commented May 14, 2024

Thank @SMillerDev for the sign-off. Is there anything I need to do now to move this along in the Brew context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosquash Automatically squash pull request commits according to Homebrew style. go Go use is a significant feature of the PR or issue new formula PR adds a new formula to Homebrew/homebrew-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants