Repository: go-task/task
Pull request #358 (2020-08-12 13:59:29)

Allow usage as an external library
The scope of this PR is to just move `args` and `taskfile` packages to the root directory. With those changes, as mentioned by @andreynering  in [this issue](https://github.com/go-task/task/issues/121), this is a minimal effort to enable usage as an external library. This still won't make usage a lib officially supported. It will only make it possible to use it on one's own risk (that some people - like me - are willing to take).


andreynering: Hi @damian-szulc, thanks for opening this Pull Request!

I'm closing this because we aren't touching v2 (currently in `master`) often anymore.

You should open another PR targeting `v3` (which will hopefully reach `master` and be released soon 🙏)
andreynering: UPDATE: `v3` was merged into `master` sooner today, so this just needs to be updated...

Patch:
diff --git a/internal/args/args.go b/args/args.go
similarity index 96%
rename from internal/args/args.go
rename to args/args.go
index e152b8f0..b172f41f 100644
--- a/internal/args/args.go
+++ b/args/args.go
@@ -3,7 +3,7 @@ package args
 import (
 	"strings"
 
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 // ParseV3 parses command line argument: tasks and global variables
diff --git a/cmd/task/task.go b/cmd/task/task.go
index 9d0e2555..ec394ca6 100644
--- a/cmd/task/task.go
+++ b/cmd/task/task.go
@@ -10,9 +10,9 @@ import (
 	"syscall"
 
 	"github.com/go-task/task/v3"
-	"github.com/go-task/task/v3/internal/args"
+	"github.com/go-task/task/v3/args"
 	"github.com/go-task/task/v3/internal/logger"
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 
 	"github.com/spf13/pflag"
 )
diff --git a/help.go b/help.go
index 2fa6c42b..af12ddcb 100644
--- a/help.go
+++ b/help.go
@@ -6,7 +6,7 @@ import (
 	"text/tabwriter"
 
 	"github.com/go-task/task/v3/internal/logger"
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 // PrintTasksHelp prints help os tasks that have a description
diff --git a/internal/compiler/compiler.go b/internal/compiler/compiler.go
index ea1ec49d..43191336 100644
--- a/internal/compiler/compiler.go
+++ b/internal/compiler/compiler.go
@@ -1,7 +1,7 @@
 package compiler
 
 import (
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 // Compiler handles compilation of a task before its execution.
diff --git a/internal/compiler/env.go b/internal/compiler/env.go
index 068a5846..b68e8ac1 100644
--- a/internal/compiler/env.go
+++ b/internal/compiler/env.go
@@ -4,7 +4,7 @@ import (
 	"os"
 	"strings"
 
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 // GetEnviron the all return all environment variables encapsulated on a
diff --git a/internal/compiler/v2/compiler_v2.go b/internal/compiler/v2/compiler_v2.go
index 1205a26c..10af3ce2 100644
--- a/internal/compiler/v2/compiler_v2.go
+++ b/internal/compiler/v2/compiler_v2.go
@@ -10,8 +10,8 @@ import (
 	"github.com/go-task/task/v3/internal/compiler"
 	"github.com/go-task/task/v3/internal/execext"
 	"github.com/go-task/task/v3/internal/logger"
-	"github.com/go-task/task/v3/internal/taskfile"
 	"github.com/go-task/task/v3/internal/templater"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 var _ compiler.Compiler = &CompilerV2{}
diff --git a/internal/compiler/v3/compiler_v3.go b/internal/compiler/v3/compiler_v3.go
index 16fdd9eb..ae3a8479 100644
--- a/internal/compiler/v3/compiler_v3.go
+++ b/internal/compiler/v3/compiler_v3.go
@@ -10,8 +10,8 @@ import (
 	"github.com/go-task/task/v3/internal/compiler"
 	"github.com/go-task/task/v3/internal/execext"
 	"github.com/go-task/task/v3/internal/logger"
-	"github.com/go-task/task/v3/internal/taskfile"
 	"github.com/go-task/task/v3/internal/templater"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 var _ compiler.Compiler = &CompilerV3{}
diff --git a/internal/summary/summary.go b/internal/summary/summary.go
index ba72d442..4b96c3d9 100644
--- a/internal/summary/summary.go
+++ b/internal/summary/summary.go
@@ -4,7 +4,7 @@ import (
 	"strings"
 
 	"github.com/go-task/task/v3/internal/logger"
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 func PrintTasks(l *logger.Logger, t *taskfile.Taskfile, c []taskfile.Call) {
diff --git a/internal/templater/templater.go b/internal/templater/templater.go
index 782ee74f..4f13c3ed 100644
--- a/internal/templater/templater.go
+++ b/internal/templater/templater.go
@@ -5,7 +5,7 @@ import (
 	"strings"
 	"text/template"
 
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 // Templater is a help struct that allow us to call "replaceX" funcs multiple
diff --git a/precondition.go b/precondition.go
index f1a64a63..aa739f9a 100644
--- a/precondition.go
+++ b/precondition.go
@@ -6,7 +6,7 @@ import (
 
 	"github.com/go-task/task/v3/internal/execext"
 	"github.com/go-task/task/v3/internal/logger"
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 var (
diff --git a/status.go b/status.go
index 709f83fb..855a60f1 100644
--- a/status.go
+++ b/status.go
@@ -7,7 +7,7 @@ import (
 	"github.com/go-task/task/v3/internal/execext"
 	"github.com/go-task/task/v3/internal/logger"
 	"github.com/go-task/task/v3/internal/status"
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 // Status returns an error if any the of given tasks is not up-to-date
diff --git a/task.go b/task.go
index 74cbb536..2709ecdb 100644
--- a/task.go
+++ b/task.go
@@ -16,8 +16,8 @@ import (
 	"github.com/go-task/task/v3/internal/logger"
 	"github.com/go-task/task/v3/internal/output"
 	"github.com/go-task/task/v3/internal/summary"
-	"github.com/go-task/task/v3/internal/taskfile"
-	"github.com/go-task/task/v3/internal/taskfile/read"
+	"github.com/go-task/task/v3/taskfile"
+	"github.com/go-task/task/v3/taskfile/read"
 
 	"golang.org/x/sync/errgroup"
 )
diff --git a/internal/taskfile/read/taskfile.go b/taskfile/read/taskfile.go
similarity index 98%
rename from internal/taskfile/read/taskfile.go
rename to taskfile/read/taskfile.go
index c7cfc912..d999e7fd 100644
--- a/internal/taskfile/read/taskfile.go
+++ b/taskfile/read/taskfile.go
@@ -7,8 +7,8 @@ import (
 	"path/filepath"
 	"runtime"
 
-	"github.com/go-task/task/v3/internal/taskfile"
 	"github.com/go-task/task/v3/internal/templater"
+	"github.com/go-task/task/v3/taskfile"
 
 	"github.com/joho/godotenv"
 	"gopkg.in/yaml.v3"
diff --git a/internal/taskfile/read/taskvars.go b/taskfile/read/taskvars.go
similarity index 94%
rename from internal/taskfile/read/taskvars.go
rename to taskfile/read/taskvars.go
index 9698d799..1d7fbf0c 100644
--- a/internal/taskfile/read/taskvars.go
+++ b/taskfile/read/taskvars.go
@@ -6,7 +6,7 @@ import (
 	"path/filepath"
 	"runtime"
 
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 
 	"gopkg.in/yaml.v3"
 )
diff --git a/internal/taskfile/task.go b/taskfile/task.go
similarity index 100%
rename from internal/taskfile/task.go
rename to taskfile/task.go
diff --git a/internal/taskfile/taskfile.go b/taskfile/taskfile.go
similarity index 98%
rename from internal/taskfile/taskfile.go
rename to taskfile/taskfile.go
index 5c6308d2..4c53c296 100644
--- a/internal/taskfile/taskfile.go
+++ b/taskfile/taskfile.go
@@ -31,7 +31,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
 		Env        *Vars
 		Tasks      Tasks
 		Silent     bool
-		Dotenv 	   []string
+		Dotenv     []string
 	}
 	if err := unmarshal(&taskfile); err != nil {
 		return err
diff --git a/internal/taskfile/var.go b/taskfile/var.go
similarity index 100%
rename from internal/taskfile/var.go
rename to taskfile/var.go
diff --git a/variables.go b/variables.go
index 87a9764c..649bac4a 100644
--- a/variables.go
+++ b/variables.go
@@ -6,8 +6,8 @@ import (
 
 	"github.com/go-task/task/v3/internal/execext"
 	"github.com/go-task/task/v3/internal/status"
-	"github.com/go-task/task/v3/internal/taskfile"
 	"github.com/go-task/task/v3/internal/templater"
+	"github.com/go-task/task/v3/taskfile"
 )
 
 // CompiledTask returns a copy of a task, but replacing variables in almost all
diff --git a/watch.go b/watch.go
index 8c64c022..01c95147 100644
--- a/watch.go
+++ b/watch.go
@@ -9,7 +9,7 @@ import (
 	"time"
 
 	"github.com/go-task/task/v3/internal/logger"
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 	"github.com/mattn/go-zglob"
 	"github.com/radovskyb/watcher"
 )


Test patch:
diff --git a/internal/args/args_test.go b/args/args_test.go
similarity index 97%
rename from internal/args/args_test.go
rename to args/args_test.go
index 086a9d2a..55676f8e 100644
--- a/internal/args/args_test.go
+++ b/args/args_test.go
@@ -4,8 +4,8 @@ import (
 	"fmt"
 	"testing"
 
-	"github.com/go-task/task/v3/internal/args"
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/args"
+	"github.com/go-task/task/v3/taskfile"
 
 	"github.com/stretchr/testify/assert"
 )
diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go
index 2cc3ab9d..30f70ed0 100644
--- a/internal/summary/summary_test.go
+++ b/internal/summary/summary_test.go
@@ -7,7 +7,7 @@ import (
 
 	"github.com/go-task/task/v3/internal/logger"
 	"github.com/go-task/task/v3/internal/summary"
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 
 	"github.com/stretchr/testify/assert"
 )
diff --git a/task_test.go b/task_test.go
index 4a35b274..c757fa54 100644
--- a/task_test.go
+++ b/task_test.go
@@ -12,7 +12,7 @@ import (
 	"testing"
 
 	"github.com/go-task/task/v3"
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 
 	"github.com/stretchr/testify/assert"
 )
diff --git a/internal/taskfile/call.go b/taskfile/call.go
similarity index 100%
rename from internal/taskfile/call.go
rename to taskfile/call.go
diff --git a/internal/taskfile/cmd.go b/taskfile/cmd.go
similarity index 100%
rename from internal/taskfile/cmd.go
rename to taskfile/cmd.go
diff --git a/internal/taskfile/included_taskfile.go b/taskfile/included_taskfile.go
similarity index 100%
rename from internal/taskfile/included_taskfile.go
rename to taskfile/included_taskfile.go
diff --git a/internal/taskfile/merge.go b/taskfile/merge.go
similarity index 100%
rename from internal/taskfile/merge.go
rename to taskfile/merge.go
diff --git a/internal/taskfile/precondition.go b/taskfile/precondition.go
similarity index 100%
rename from internal/taskfile/precondition.go
rename to taskfile/precondition.go
diff --git a/internal/taskfile/precondition_test.go b/taskfile/precondition_test.go
similarity index 95%
rename from internal/taskfile/precondition_test.go
rename to taskfile/precondition_test.go
index cbeb9265..7eb84a2d 100644
--- a/internal/taskfile/precondition_test.go
+++ b/taskfile/precondition_test.go
@@ -3,7 +3,7 @@ package taskfile_test
 import (
 	"testing"
 
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 
 	"github.com/stretchr/testify/assert"
 	"gopkg.in/yaml.v3"
diff --git a/internal/taskfile/taskfile_test.go b/taskfile/taskfile_test.go
similarity index 96%
rename from internal/taskfile/taskfile_test.go
rename to taskfile/taskfile_test.go
index 092bc1d5..6a13f049 100644
--- a/internal/taskfile/taskfile_test.go
+++ b/taskfile/taskfile_test.go
@@ -3,7 +3,7 @@ package taskfile_test
 import (
 	"testing"
 
-	"github.com/go-task/task/v3/internal/taskfile"
+	"github.com/go-task/task/v3/taskfile"
 
 	"github.com/stretchr/testify/assert"
 	"gopkg.in/yaml.v3"