Skip to content

Commit

Permalink
Merge pull request #13 from ivanilves/no-shell
Browse files Browse the repository at this point in the history
feat: decommission shell package
  • Loading branch information
ivanilves authored Oct 22, 2022
2 parents 54da685 + 19c9b28 commit 8a86a4c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 164 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# travelgrunt

**T**ravel **T**erra**g**runt directory tree as a first class passenger! :sunglasses:
Travel **[Terragrunt](https://terragrunt.gruntwork.io/)** directory tree as a first class passenger! :airplane:

## How to use?

* `cd` to the directory of your [locally cloned] Terragrunt/Terraform Git repo;
* run `travelgrunt` command there :rocket: ([optional] arguments are "path filter" matches);
* use arrow keys to navigate the list and `/` key to search for specific projects;
* run **tg** alias there :rocket: ([optional] arguments are "path filter" matches);
* use arrow keys to navigate the list and `/` key to search for specific items;

## Shell aliases

It is **highly** recommended to use `bash` (or `zsh`) aliases. Start from something like this:
It is **absolutelly required** to use `bash` (or `zsh`) aliases. Start from something like this:
```
alias tg='_tg(){ travelgrunt --out-file ~/.tg-path ${@} && cd "$(cat ~/.tg-path)" }; _tg'
alias tt='_tt(){ travelgrunt --top --out-file ~/.tg-path && cd "$(cat ~/.tg-path)" }; _tt'
```

:bulb: `travelgrunt --top` is a "shortcut" that brings you to the top level path of your repository.
:bulb: **tt** is a "convenience alias" that brings you to the top level path of your repository.

### Why aliases?
Core aspect of this program is the ability to change working directory while staying **inside the current shell**.
This can not be done by the program itself, because of obvious security related `POSIX` limitations. Without instrumenting
the shell with aliases `travelgrunt` still can kinda work, but will provide you with much more awkward and second class user
experience, i.e. you will need to exit subshell before you "jump" to the next project. :weary:
Core feature of this program is the ability to change working directory while staying **inside the current shell**.
This **can not** be done by the program itself, because of `POSIX` security limitations. Without instrumenting
the shell with aliases `travelgrunt` will not work!

## How to build?

Expand Down
9 changes: 2 additions & 7 deletions cmd/travelgrunt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/ivanilves/travelgrunt/pkg/filter"
"github.com/ivanilves/travelgrunt/pkg/menu"
"github.com/ivanilves/travelgrunt/pkg/scm"
"github.com/ivanilves/travelgrunt/pkg/shell"
"github.com/ivanilves/travelgrunt/pkg/terminal"
)

Expand All @@ -28,7 +27,7 @@ func init() {
}

func usage() {
println("Usage: " + shell.Name() + " [<match> <match2> ... <matchN>]")
println("Usage: " + os.Args[0] + " [<match> <match2> ... <matchN>]")
println("")
println("Options:")
flag.PrintDefaults()
Expand All @@ -43,10 +42,6 @@ func writeFileAndExit(fileName string, data string) {
}

func main() {
if shell.IsRunningInside() {
log.Fatalf("%s already running (pid: %d), please type \"exit\" to return to the parent shell first", shell.Name(), shell.Getppid())
}

flag.Usage = usage
flag.Parse()

Expand Down Expand Up @@ -104,5 +99,5 @@ func main() {
writeFileAndExit(outFile, entries[selected])
}

shell.Spawn(entries[selected])
log.Fatal("Please configure shell aliases as described: https://github.com/ivanilves/travelgrunt#shell-aliases")
}
62 changes: 0 additions & 62 deletions pkg/shell/shell.go

This file was deleted.

86 changes: 0 additions & 86 deletions pkg/shell/shell_test.go

This file was deleted.

0 comments on commit 8a86a4c

Please sign in to comment.