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 Jun 28, 2023
1 parent 3843596 commit b18db02
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.21/gt-macos"
sha256 "7d4f2dd797e105cc1d801ad5ab84d0faaa43abf434cb40997f68f198d9eb337d"
def install
bin.install "gt-macos" => "gt"
end
end

if OS.linux?
url "https://github.com/withgraphite/graphite-cli/releases/download/v0.20.21/gt-linux"
sha256 "14f66826a75728e7e09f00e41fbc4f4c11395eb03ca5cdbe34789c065d640c10"
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 b18db02

Please sign in to comment.