Skip to content

Commit

Permalink
Allow using aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolftimmermans committed Oct 28, 2024
1 parent 596495c commit 0aeeacf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.3.0

* Introduce aliases `kbuild` for `kd build`, `kdeploy` for `kd deploy` and `kctl` for `kd ctl`.

# v2.2.1

* Fix issues that prevented the `kd ctl` command from working.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
1. Ensure you have `~/.bin` directory or similar that is in your `$PATH`
2. Install KD:

- When using an Apple M1+ Mac run: `rm -f ~/.bin/kd && curl -L $(curl -s https://api.github.com/repos/voormedia/kd/releases/latest | grep browser_download_url | grep darwin_arm64 | cut -d '"' -f 4) -o ~/.bin/kd && chmod +x ~/.bin/kd`
- When using an Intel Mac run: `rm -f ~/.bin/kd && curl -L $(curl -s https://api.github.com/repos/voormedia/kd/releases/latest | grep browser_download_url | grep darwin_amd64 | cut -d '"' -f 4) -o ~/.bin/kd && chmod +x ~/.bin/kd`
- When using an Apple M1+ Mac run: `rm -f ~/.bin/kd && curl -L $(curl -s https://api.github.com/repos/voormedia/kd/releases/latest | grep browser_download_url | grep darwin_arm64 | cut -d '"' -f 4) -o ~/.bin/kd && chmod +x ~/.bin/kd && ln -sf ~/.bin/kd ~/.bin/kbuild && ln -sf ~/.bin/kd ~/.bin/kdeploy && ln -sf ~/.bin/kd ~/.bin/kctl`
- When using an Intel Mac run: `rm -f ~/.bin/kd && curl -L $(curl -s https://api.github.com/repos/voormedia/kd/releases/latest | grep browser_download_url | grep darwin_amd64 | cut -d '"' -f 4) -o ~/.bin/kd && chmod +x ~/.bin/kd && ln -sf ~/.bin/kd ~/.bin/kbuild && ln -sf ~/.bin/kd ~/.bin/kdeploy && ln -sf ~/.bin/kd ~/.bin/kctl`

3. Install Google Cloud credential helper:

Expand All @@ -36,7 +36,7 @@ example, to expose the SSH key `id_ed25519` to `kd`, execute the following:

`ssh-add ~/.ssh/id_ed25519`

In case your .ssh folder does not contain the file `id_ed25519` but `id_rsa`, use the following command:
In case your .ssh folder does not contain the file `id_ed25519` but `id_rsa`, use the following command:

`ssh-add ~/.ssh/id_rsa`

Expand Down
18 changes: 18 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"os"
"path/filepath"

"github.com/spf13/cobra"
"github.com/voormedia/kd/pkg/util"
)
Expand All @@ -23,6 +26,21 @@ func init() {
cmdRoot.PersistentFlags().Bool("verbose", false, "verbose output")
}

func setCommand(cmdRoot *cobra.Command, command string) {
cmdRoot.SetArgs(append([]string{command}, os.Args[1:]...))
}

func Execute() {
executableName := filepath.Base(os.Args[0])

switch executableName {
case "kbuild":
setCommand(cmdRoot, "build")
case "kctl":
setCommand(cmdRoot, "ctl")
case "kdeploy":
setCommand(cmdRoot, "deploy")
}

cmdRoot.Execute()
}
1 change: 1 addition & 0 deletions kbuild
1 change: 1 addition & 0 deletions kctl
1 change: 1 addition & 0 deletions kdeploy

0 comments on commit 0aeeacf

Please sign in to comment.