From 028f3da0c62c17af9ab7cdf81d5e9b75b601b825 Mon Sep 17 00:00:00 2001 From: Andrii Nechaiev Date: Mon, 16 Jun 2025 14:54:28 +0000 Subject: [PATCH] rename start -> go --- README.md | 8 ++++---- cmd/{start.go => go.go} | 10 +++++----- cmd/root.go | 2 +- internal/app/wdir.go | 6 +++--- internal/app/wdir_test.go | 18 +++++++++--------- 5 files changed, 22 insertions(+), 22 deletions(-) rename cmd/{start.go => go.go} (89%) diff --git a/README.md b/README.md index 651060f..f2e3647 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 [more projects] [options] +gw go [more projects] [options] ``` This command will: @@ -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: diff --git a/cmd/start.go b/cmd/go.go similarity index 89% rename from cmd/start.go rename to cmd/go.go index c7bf698..2521031 100644 --- a/cmd/start.go +++ b/cmd/go.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/cobra" ) -func buildStartCommand() *cobra.Command { +func buildGoCommand() *cobra.Command { var ( open bool directory string @@ -14,7 +14,7 @@ func buildStartCommand() *cobra.Command { ) cmd := &cobra.Command{ - Use: "start ...", + Use: "go ...", 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. @@ -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, }, ) @@ -53,5 +53,5 @@ Override the editor using -e/--editor. } func init() { - rootCmd.AddCommand(buildStartCommand()) + rootCmd.AddCommand(buildGoCommand()) } diff --git a/cmd/root.go b/cmd/root.go index 8679474..1f5c24f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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 --open +gw go --open gw done `, } diff --git a/internal/app/wdir.go b/internal/app/wdir.go index 880c449..0bfeed2 100644 --- a/internal/app/wdir.go +++ b/internal/app/wdir.go @@ -27,7 +27,7 @@ func NewWorkingDir(directory string, config Config, cache ICache) WorkingDir { } } -type StartOpts struct { +type GoOpts struct { Open bool } @@ -35,9 +35,9 @@ 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) diff --git a/internal/app/wdir_test.go b/internal/app/wdir_test.go index fa5dfc6..ef43d8f 100644 --- a/internal/app/wdir_test.go +++ b/internal/app/wdir_test.go @@ -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"}) @@ -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) @@ -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"] @@ -211,7 +211,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"] @@ -219,12 +219,12 @@ func TestStart(t *testing.T) { }) 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) { @@ -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) }) @@ -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"}}) })