Coder Social home page Coder Social logo

Add `rnr` to Homebrew about rnr HOT 16 CLOSED

ismaelgv avatar ismaelgv commented on August 18, 2024 1
Add `rnr` to Homebrew

from rnr.

Comments (16)

ivaquero avatar ivaquero commented on August 18, 2024 1

Good suggestion. I will look into it.

from rnr.

ivaquero avatar ivaquero commented on August 18, 2024 1

A PR has been made: Homebrew/homebrew-core#115749

Please keep an eye.

from rnr.

ivaquero avatar ivaquero commented on August 18, 2024 1

You are welcome. Thank you for this helpful tool.

from rnr.

ivaquero avatar ivaquero commented on August 18, 2024 1

The PR has been accepted! This issue can be closed.

from rnr.

ismaelgv avatar ismaelgv commented on August 18, 2024

Thanks @Miserlou! I have no experience with Homebrew nor access to a MacOS system.

Any contribution will be more than welcome.

from rnr.

ivaquero avatar ivaquero commented on August 18, 2024

Hi, @ismaelgv, I'm trying to create a Homebrew script, but failed

The file is

class Rnr < Formula
  desc "Command-line tool to batch rename files and directories"
  homepage "https://github.com/ismaelgv/rnr"
  url "https://github.com/ismaelgv/rnr/archive/refs/tags/v0.4.1.tar.gz"
  sha256 "85013be46725acc1cd6f2d2089c42f426c052efab26d22db8a9f28051eebbb6a"
  license "MIT"

  depends_on "rust" => :build

  def install
    system "cargo", "install", "--locked", *std_cargo_args
    generate_completions_from_executable(bin/"rnr", "gen_completions", base_name: "rnr")
  end

  test do
    # Check that a typical Conventional Commit is considered correct.
    system "git", "init"
    (testpath/"some-file").write("")
    system "git", "add", "some-file"
    system "git", "config", "user.name", "'Ismael González Valverde'"
    system "git", "config", "user.email", "[email protected]"
    system "git", "commit", "-m", "chore: initial commit"
    assert_equal "No errored commits", shell_output("#{bin}/rnr check 2>&1").strip
  end
end

The error message is

Failure while executing; `\{\"SHELL\"=\>\"bash\"\} /opt/homebrew/Cellar/rnr/0.4.1/bin/rnr gen_completions bash` exited with 1. Here's the output:

This is the result of wrong command of generate_completions functionality, then what is the exact command ?

I am sure it is not hard for you to understand the message as well as the manuscript above.

from rnr.

ismaelgv avatar ismaelgv commented on August 18, 2024

Thanks for trying to pack RnR for Homebrew. I got no experience with that package manager, but I will take a look at the problem of the completion generation as soon as possible.

from rnr.

ismaelgv avatar ismaelgv commented on August 18, 2024

@ivaquero I think that you do not need to generate anything manually. The completion files are generated when you build the project, not with any additional command. You would need to package the completions.

You can take a look to bat formulae to use it as reference.

You can also check the current CI/CD configuration that generates the release:
https://github.com/ismaelgv/rnr/blob/master/.github/workflows/release.yml#L67-L105

from rnr.

ivaquero avatar ivaquero commented on August 18, 2024

For now, the script can successfully be built

class Rnr < Formula
  desc "Command-line tool to batch rename files and directories"
  homepage "https://github.com/ismaelgv/rnr"
  url "https://github.com/ismaelgv/rnr/archive/refs/tags/v0.4.1.tar.gz"
  sha256 "85013be46725acc1cd6f2d2089c42f426c052efab26d22db8a9f28051eebbb6a"
  license "MIT"

  depends_on "rust" => :build

  def install
    ENV["SHELL_COMPLETIONS_DIR"] = buildpath
    system "cargo", "install", *std_cargo_args

    deploy_dir = Dir["target/release/build/rnr-*/out"].first
    bash_completion.install "#{deploy_dir}/rnr.bash" => "rnr"
    fish_completion.install "#{deploy_dir}/rnr.fish"
    # zsh_completion.install "#{deploy_dir}/rnr.zsh" => "rnr"
  end

  test do
  end
end
rnr -h
rnr 0.4.1
Ismael González Valverde <[email protected]>
RnR is a command-line tool to rename multiple files and directories that
supports regular expressions

USAGE:
    rnr [FLAGS] [OPTIONS] <EXPRESSION> <REPLACEMENT> <PATH(S)>...
    rnr [FLAGS] [OPTIONS] <SUBCOMMAND>
....

However, there are several missing parts

  • zsh_completion, the CI doesn't include zsh
  • test function, I am not sure the best way to test rnr, I wonder whether to use the previous one

from rnr.

ismaelgv avatar ismaelgv commented on August 18, 2024

zsh_completion, the CI doesn't include zsh

The CI is generating the ZSH completion, but the file is called _rnr. You need to correct that in the script.

test function, I am not sure the best way to test rnr, I wonder whether to use the previous one

All the testing is running in the CI system of the project (Github Actions). I am not sure why it is needed to be run in the Homebrew again.

from rnr.

ivaquero avatar ivaquero commented on August 18, 2024

Okay, it build past, but it seems the competion doesn't work correctly

class Rnr < Formula
  desc "Command-line tool to batch rename files and directories"
  homepage "https://github.com/ismaelgv/rnr"
  url "https://github.com/ismaelgv/rnr/archive/refs/tags/v0.4.1.tar.gz"
  sha256 "85013be46725acc1cd6f2d2089c42f426c052efab26d22db8a9f28051eebbb6a"
  license "MIT"

  depends_on "rust" => :build

  def install
    ENV["SHELL_COMPLETIONS_DIR"] = buildpath
    system "cargo", "install", *std_cargo_args

    deploy_dir = Dir["target/release/build/rnr-*/out"].first
    zsh_completion.install "#{deploy_dir}/_rnr" => "rnr"
    bash_completion.install "#{deploy_dir}/rnr.bash" => "rnr"
    fish_completion.install "#{deploy_dir}/rnr.fish"
  end

  test do
  end
end

I will check what to put in the test sectioin.

from rnr.

ismaelgv avatar ismaelgv commented on August 18, 2024

@ivaquero I think you need to copy ZSH completion file as it is _rnr, you are renaming it to rnr.

If you want to test something you may want to rename a dummy file. For example, the bat example is just checking that the CLI tool is functional printing the content of a file.

from rnr.

ivaquero avatar ivaquero commented on August 18, 2024

No problem, I will try.

I suggest that you create a new repo to host this Homebrew script and mention it in the README, because Homebrew official has a relatively strict standard, we need more time and users to test to avoid the PR to be closed accidentally.

from rnr.

ismaelgv avatar ismaelgv commented on August 18, 2024

Feel free to host it yourself until it is merged to Homebrew official repository. I cannot provide proper support to that script since I cannot test it. However, you can maintain it if it is fine for you.

I will add the information to the README.md once it is ready.

Thanks for your contribution to the project! 😉

from rnr.

ismaelgv avatar ismaelgv commented on August 18, 2024

@ivaquero I see that they approved the PR, thanks for the contribution! I will add the information to the README.md.

from rnr.

ismaelgv avatar ismaelgv commented on August 18, 2024

I will update the readme before closing this issue. I am a bit busy these days so it may take me some time. Thanks!

from rnr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.