-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from gsamokovarov/autojump-importer
Introduce autojump and z configuration importers
- Loading branch information
Showing
28 changed files
with
727 additions
and
64 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
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
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
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,20 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/gsamokovarov/jump/cli" | ||
"github.com/gsamokovarov/jump/config" | ||
"github.com/gsamokovarov/jump/importer" | ||
"github.com/gsamokovarov/jump/scoring" | ||
) | ||
|
||
func importCmd(args cli.Args, conf config.Config) error { | ||
imp := importer.Guess(args.CommandName(), conf) | ||
|
||
return imp.Import(func(entry *scoring.Entry) { | ||
cli.Outf("Importing %s\n", entry.Path) | ||
}) | ||
} | ||
|
||
func init() { | ||
cli.RegisterCommand("import", "Import autojump or z scores.", importCmd) | ||
} |
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,79 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/gsamokovarov/assert" | ||
"github.com/gsamokovarov/jump/cli" | ||
"github.com/gsamokovarov/jump/config" | ||
) | ||
|
||
func Test_importCmd_autojump(t *testing.T) { | ||
oldHOME := os.Getenv("HOME") | ||
defer os.Setenv("HOME", oldHOME) | ||
|
||
os.Setenv("HOME", td) | ||
|
||
conf := &config.Testing{} | ||
|
||
output := capture(&os.Stdout, func() { | ||
assert.Nil(t, importCmd(cli.Args{"autojump"}, conf)) | ||
}) | ||
|
||
assert.Equal(t, `Importing /Users/genadi/Development/jump | ||
Importing /Users/genadi/Development/mock_last_status | ||
Importing /Users/genadi/Development | ||
Importing /Users/genadi/.go/src/github.com/gsamokovarov/jump | ||
Importing /usr/local/Cellar/autojump | ||
Importing /Users/genadi/Development/gloat | ||
`, output) | ||
|
||
assert.Len(t, 6, conf.Entries) | ||
} | ||
|
||
func Test_importCmd_z(t *testing.T) { | ||
oldHOME := os.Getenv("HOME") | ||
defer os.Setenv("HOME", oldHOME) | ||
|
||
os.Setenv("HOME", td) | ||
|
||
conf := &config.Testing{} | ||
|
||
output := capture(&os.Stdout, func() { | ||
assert.Nil(t, importCmd(cli.Args{"z"}, conf)) | ||
}) | ||
|
||
assert.Equal(t, `Importing /Users/genadi/Development/hack | ||
Importing /Users/genadi/Development/masse | ||
Importing /Users/genadi/Development | ||
Importing /Users/genadi/.go/src/github.com/gsamokovarov/jump | ||
`, output) | ||
|
||
assert.Len(t, 4, conf.Entries) | ||
} | ||
|
||
func Test_importCmd_itALL(t *testing.T) { | ||
oldHOME := os.Getenv("HOME") | ||
defer os.Setenv("HOME", oldHOME) | ||
|
||
os.Setenv("HOME", td) | ||
|
||
conf := &config.Testing{} | ||
|
||
output := capture(&os.Stdout, func() { | ||
assert.Nil(t, importCmd(cli.Args{""}, conf)) | ||
}) | ||
|
||
assert.Equal(t, `Importing /Users/genadi/Development/hack | ||
Importing /Users/genadi/Development/masse | ||
Importing /Users/genadi/Development | ||
Importing /Users/genadi/.go/src/github.com/gsamokovarov/jump | ||
Importing /Users/genadi/Development/jump | ||
Importing /Users/genadi/Development/mock_last_status | ||
Importing /usr/local/Cellar/autojump | ||
Importing /Users/genadi/Development/gloat | ||
`, output) | ||
|
||
assert.Len(t, 8, conf.Entries) | ||
} |
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,6 @@ | ||
38.729833462 /Users/genadi/Development/jump | ||
14.1421356237 /Users/genadi/Development/mock_last_status | ||
33.1662479035 /Users/genadi/Development | ||
14.1421356237 /Users/genadi/.go/src/github.com/gsamokovarov/jump | ||
43.5889894353 /usr/local/Cellar/autojump | ||
20.0 /Users/genadi/Development/gloat |
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,4 @@ | ||
/Users/genadi/Development/hack|11|1536272816 | ||
/Users/genadi/Development/masse|1|1536272502 | ||
/Users/genadi/Development|3|1536272506 | ||
/Users/genadi/.go/src/github.com/gsamokovarov/jump|1|1536272492 |
Oops, something went wrong.