Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You define a working directory and use the tool to start/stop working on a proje
### Basic usage
Start the project and open it:
```bash
gw start myproject --open
gw go myproject --open
```

When done, make it done:
Expand Down Expand Up @@ -60,10 +60,10 @@ Configuration example:
```

### Start to work on a project
When it is time to work on some project, use the `start` command:
When it is time to work on some project, use the `go` command:

```bash
gw start <project_name> [more projects] [options]
gw go <project_name> [more projects] [options]
```

This command will:
Expand All @@ -75,7 +75,7 @@ This command will:
* clone it from git sources into the working directory
* open the project with a configured editor if the `-o/--open` flag is set

See `gw start --help` for other available options on how to control the command.
See `gw go --help` for other available options on how to control the command.

### Finish your work with a project
When you are done with your work, use `done` command:
Expand Down
10 changes: 5 additions & 5 deletions cmd/start.go → cmd/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/spf13/cobra"
)

func buildStartCommand() *cobra.Command {
func buildGoCommand() *cobra.Command {
var (
open bool
directory string
Expand All @@ -14,7 +14,7 @@ func buildStartCommand() *cobra.Command {
)

cmd := &cobra.Command{
Use: "start <project>...",
Use: "go <project>...",
Short: "Start the project",
Long: `Clone the project (if needed) into the working directory.
Sources from the configuration are used but may be extended by -s/--source.
Expand All @@ -32,11 +32,11 @@ Override the editor using -e/--editor.
cache := app.NewCacheFromFile()
ensureDir(&directory, config.Dir)
wd := app.NewWorkingDir(directory, config, cache)
return wd.Start(
return wd.Go(
args,
sources,
editor,
app.StartOpts{
app.GoOpts{
Open: open,
},
)
Expand All @@ -53,5 +53,5 @@ Override the editor using -e/--editor.
}

func init() {
rootCmd.AddCommand(buildStartCommand())
rootCmd.AddCommand(buildGoCommand())
}
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var rootCmd = &cobra.Command{
Safely remove projects from the working directory (the tool will ensure you
have not left anything unpublished).

gw start <project> --open
gw go <project> --open
gw done <project>
`,
}
Expand Down
6 changes: 3 additions & 3 deletions internal/app/wdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ func NewWorkingDir(directory string, config Config, cache ICache) WorkingDir {
}
}

type StartOpts struct {
type GoOpts struct {
Open bool
}

type DoneOpts struct {
Force bool
}

func (wd WorkingDir) Start(projects, sources []string, editor string, opts StartOpts) error {
func (wd WorkingDir) Go(projects, sources []string, editor string, opts GoOpts) error {
if len(projects) == 0 {
return fmt.Errorf("no projects to start specified")
return fmt.Errorf("no projects to go specified")
}
var lastProjectPath string
editors := wd.getEditors(editor)
Expand Down
18 changes: 9 additions & 9 deletions internal/app/wdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func buildWorkingDir(comps wdComponents) WorkingDir {
}
}

func TestStart(t *testing.T) {
func TestGo(t *testing.T) {
t.Run("no project; cloned; not opened", func(t *testing.T) {
fs := NewFakeFS()
git := NewFakeGit(fs).WithSources([]string{"dsource/proj", "dsource2/proj"})
Expand All @@ -171,11 +171,11 @@ func TestStart(t *testing.T) {
git: git,
},
)
err := wd.Start(
err := wd.Go(
[]string{"proj"},
[]string{"dsource", "dsource2"},
"vi",
StartOpts{Open: false},
GoOpts{Open: false},
)

require.NoError(t, err)
Expand All @@ -192,7 +192,7 @@ func TestStart(t *testing.T) {
git: git,
},
)
err := wd.Start([]string{"proj"}, []string{"dsource"}, "vim", StartOpts{Open: true})
err := wd.Go([]string{"proj"}, []string{"dsource"}, "vim", GoOpts{Open: true})
require.NoError(t, err)

repo := fs.repos["/dwd/proj"]
Expand All @@ -211,20 +211,20 @@ func TestStart(t *testing.T) {
git: git,
},
)
err := wd.Start([]string{"proj"}, []string{"dsource"}, "vim", StartOpts{Open: true})
err := wd.Go([]string{"proj"}, []string{"dsource"}, "vim", GoOpts{Open: true})
require.NoError(t, err)

repo := fs.repos["/dwd/proj"]
require.Equal(t, repo.opensCount, 1)
})
t.Run("projects are empty", func(t *testing.T) {
wd := buildWorkingDir(wdComponents{})
err := wd.Start([]string{}, []string{"s1"}, "", StartOpts{})
err := wd.Go([]string{}, []string{"s1"}, "", GoOpts{})
require.Error(t, err)
})
t.Run("sources are empty", func(t *testing.T) {
wd := buildWorkingDir(wdComponents{})
err := wd.Start([]string{"p1"}, []string{}, "", StartOpts{})
err := wd.Go([]string{"p1"}, []string{}, "", GoOpts{})
require.Error(t, err)
})
t.Run("source from cache", func(t *testing.T) {
Expand All @@ -245,7 +245,7 @@ func TestStart(t *testing.T) {
cache: cache,
})

err := wd.Start([]string{"p1"}, []string{}, "", StartOpts{})
err := wd.Go([]string{"p1"}, []string{}, "", GoOpts{})
require.NoError(t, err)
require.Equal(t, cache.Writes, 1)
})
Expand All @@ -259,7 +259,7 @@ func TestStart(t *testing.T) {
cache: cache,
})

err := wd.Start([]string{"p1"}, []string{"s"}, "", StartOpts{})
err := wd.Go([]string{"p1"}, []string{"s"}, "", GoOpts{})
require.NoError(t, err)
require.Equal(t, cache.Data, map[string]ProjectInfo{"p1": {Source: "s"}})
})
Expand Down