From 4ef7699f57e7124fff4259ddcff6978756410d19 Mon Sep 17 00:00:00 2001 From: Adrian Ho Date: Tue, 4 May 2021 11:10:58 +0800 Subject: [PATCH] rclone-mac: add `rclone` alias Addresses #9 --- Formula/rclone-mac.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Formula/rclone-mac.rb b/Formula/rclone-mac.rb index 536f616..b0a3b39 100644 --- a/Formula/rclone-mac.rb +++ b/Formula/rclone-mac.rb @@ -16,21 +16,38 @@ class RcloneMac < Formula system "go", "build", "-ldflags", "-s -X github.com/rclone/rclone/fs.Version=v#{version}", "-tags", "cmount", *std_go_args + (libexec/"rclone").install_symlink bin/name.to_s => "rclone" man1.install "rclone.1" => "#{name}.1" + system bin/name.to_s, "genautocomplete", "bash", "rclone.bash" system bin/name.to_s, "genautocomplete", "bash", "#{name}.bash" + system bin/name.to_s, "genautocomplete", "zsh", "_rclone" system bin/name.to_s, "genautocomplete", "zsh", "_#{name}" inreplace "#{name}.bash" do |s| s.gsub! "commands=(\"rclone\")", "commands=(\"#{name}\")" s.gsub!(/(-F __start_rclone) rclone$/, "\\1 #{name}") end inreplace "_#{name}", /(#compdef _rclone) rclone$/, "\\1 #{name}" + bash_completion.install "rclone.bash" => "rclone" bash_completion.install "#{name}.bash" => name.to_s + zsh_completion.install "_rclone" zsh_completion.install "_#{name}" end + def caveats + <<~EOS + The rclone binary has been installed as `#{name}`, + to avoid conflict with the core `rclone` formula. + If you need to use it as `rclone`, add the "rclone" directory + to your PATH like: + PATH="#{opt_libexec}/rclone:$PATH" + EOS + end + test do (testpath/"file1.txt").write "Test!" system bin/name.to_s, "copy", testpath/"file1.txt", testpath/"dist" assert_match File.read(testpath/"file1.txt"), File.read(testpath/"dist/file1.txt") + system opt_libexec/"rclone/rclone", "copy", testpath/"file1.txt", testpath/"dast" + assert_match File.read(testpath/"file1.txt"), File.read(testpath/"dast/file1.txt") end end