Skip to content

Commit d52c23e

Browse files
committed
feat: Generate shell completions on install
Homebrew can automatically generate and install completions for bash, zsh, and fish. For now, completion is limited to bash and zsh until graphite adds fish support. This simplifies the installation steps for homebrew users.
1 parent 3843596 commit d52c23e

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

Formula/graphite.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@ class Graphite < Formula
77
if OS.mac?
88
url "https://github.com/withgraphite/graphite-cli/releases/download/v0.20.21/gt-macos"
99
sha256 "7d4f2dd797e105cc1d801ad5ab84d0faaa43abf434cb40997f68f198d9eb337d"
10-
def install
11-
bin.install "gt-macos" => "gt"
12-
end
1310
end
1411

1512
if OS.linux?
1613
url "https://github.com/withgraphite/graphite-cli/releases/download/v0.20.21/gt-linux"
1714
sha256 "14f66826a75728e7e09f00e41fbc4f4c11395eb03ca5cdbe34789c065d640c10"
18-
def install
15+
end
16+
17+
def install
18+
if OS.mac?
19+
bin.install "gt-macos" => "gt"
20+
elsif OS.linux?
1921
bin.install "gt-linux" => "gt"
20-
end
22+
end
23+
24+
chmod 0555, bin/"gt"
25+
generate_completions_from_executable(bin/"gt", "completion", shells: [:bash, :zsh, :fish], shell_parameter_format: :none)
2126
end
2227

2328
# TODO

formula-templates/graphite.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@ class Graphite < Formula
77
if OS.mac?
88
url "{{urlMac}}"
99
sha256 "{{shasumMac}}"
10-
def install
11-
bin.install "gt-macos" => "gt"
12-
end
1310
end
1411

1512
if OS.linux?
1613
url "{{urlLinux}}"
1714
sha256 "{{shasumLinux}}"
18-
def install
15+
end
16+
17+
def install
18+
if OS.mac?
19+
bin.install "gt-macos" => "gt"
20+
elsif OS.linux?
1921
bin.install "gt-linux" => "gt"
20-
end
22+
end
23+
24+
chmod 0555, bin/"gt"
25+
generate_completions_from_executable(bin/"gt", "completion", shells: [:bash, :zsh, :fish], shell_parameter_format: :none)
2126
end
2227

2328
# TODO

0 commit comments

Comments
 (0)