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 14, 2023
1 parent 19dcb83 commit 5555c43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
16 changes: 11 additions & 5 deletions Formula/graphite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ class Graphite < Formula
if OS.mac?
url "https://github.com/withgraphite/graphite-cli/releases/download/v0.20.34/gt-macos"
sha256 "acf6a53b873703fcaa190293aae33a12a5db17e0bb21c3c3713e37d771c86de1"
def install
bin.install "gt-macos" => "gt"
end
end

if OS.linux?
url "https://github.com/withgraphite/graphite-cli/releases/download/v0.20.34/gt-linux"
sha256 "61c19e9ceb2fe884b1f4f6eebaf96746ef048958c4f382a3c4dc82d6f1a95851"
def install
end

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

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

# TODO
Expand Down
16 changes: 11 additions & 5 deletions formula-templates/graphite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,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
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 5555c43

Please sign in to comment.