-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce jump pins, a command that lists all the pins
- Loading branch information
1 parent
dd82ccf
commit 00652ba
Showing
7 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/gsamokovarov/jump/cli" | ||
"github.com/gsamokovarov/jump/config" | ||
) | ||
|
||
func pinsCmd(args cli.Args, conf config.Config) error { | ||
pins, err := conf.ReadPins() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for term, dir := range pins { | ||
cli.Outf("%s\t%s\n", term, dir) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func init() { | ||
cli.RegisterCommand("pins", "Lists all the pinned search terms.", pinsCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/gsamokovarov/assert" | ||
) | ||
|
||
func Test_pinsCmd(t *testing.T) { | ||
conf := &testConfig{ | ||
Pins: map[string]string{ | ||
"r": "/home/user/projects/rails", | ||
}, | ||
} | ||
|
||
output := capture(&os.Stdout, func() { | ||
assert.Nil(t, pinsCmd(nil, conf)) | ||
}) | ||
|
||
assert.Equal(t, "r\t/home/user/projects/rails\n", output) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters