Skip to content

Commit

Permalink
gordon setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoh86 committed Apr 19, 2020
1 parent 1782721 commit 04b6407
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ then run
$ GO111MODULE=on go get github.com/kyoh86/gordon@latest
```

And you should setup shell in `.bashrc` or `.zshrc`.

```sh
eval "$(command gordon setup)"
```

## Usage

```console
Expand Down
11 changes: 11 additions & 0 deletions internal/command/setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package command

import (
"context"
"fmt"
)

func Setup(_ context.Context, ev Env) error {
fmt.Printf(`export PATH="%s:${PATH}"%s`, ev.Bin(), "\n")
return nil
}
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func main() {

dump,
restore,
setup,
} {
key, run := f(app)
cmds[key] = run
Expand Down Expand Up @@ -171,3 +172,10 @@ func update(app *kingpin.Application) (string, func() error) {
return command.Update(context.Background(), ev)
})
}

func setup(app *kingpin.Application) (string, func() error) {
cmd := app.Command("setup", "Setup shell to support gordon")
return mainutil.WrapCommand(cmd, func(ev command.Env) error {
return command.Setup(context.Background(), ev)
})
}

0 comments on commit 04b6407

Please sign in to comment.