Skip to content

Commit

Permalink
feat: Generate shell completions on install
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jalaziz committed Jul 22, 2023
1 parent 74bbc28 commit c880a52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions Formula/graphite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ class Graphite < Formula
if OS.mac?
url "https://github.com/withgraphite/homebrew-tap/releases/download/v0.21.0/gt-macos"
sha256 "b498330dbfea3810ec0822d4d106f69fe8182c9a0eefbb8b9b794500c22cc573"
def install
bin.install "gt-macos" => "gt"
end
end

if OS.linux?
url "https://github.com/withgraphite/homebrew-tap/releases/download/v0.21.0/gt-linux"
sha256 "ea22d355da93c59300ee83ac9ef58d63126c41a80d9a39076a5de9420ae789d9"
def install
end

def install
if OS.mac?
bin.install "gt-macos" => "gt"
elsif OS.linux?
bin.install "gt-linux" => "gt"
end

chmod 0555, bin/"gt"
generate_completions_from_executable(bin/"gt", "completion", shells: [:bash, :zsh, :fish],
shell_parameter_format: :none)
end

# TODO
Expand Down
14 changes: 10 additions & 4 deletions formula-templates/graphite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ class Graphite < Formula
if OS.mac?
url "{{urlMac}}"
sha256 "{{shasumMac}}"
def install
bin.install "gt-macos" => "gt"
end
end

if OS.linux?
url "{{urlLinux}}"
sha256 "{{shasumLinux}}"
def install
end

def install
if OS.mac?
bin.install "gt-macos" => "gt"
elsif OS.linux?
bin.install "gt-linux" => "gt"
end

chmod 0555, bin/"gt"
generate_completions_from_executable(bin/"gt", "completion", shells: [:bash, :zsh, :fish],
shell_parameter_format: :none)
end

# TODO
Expand Down

0 comments on commit c880a52

Please sign in to comment.