From 937c50f980c5862b1cb8d8106b3fa4479ff7d771 Mon Sep 17 00:00:00 2001 From: Bastean Date: Mon, 16 Sep 2024 01:43:44 +0000 Subject: [PATCH] docs(readme): add exec task description --- Makefile | 4 +- README.md | 115 +++++++++++++++++++++++++++++++++++------------------- 2 files changed, 76 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 4cd43d7..8f3eb57 100644 --- a/Makefile +++ b/Makefile @@ -146,10 +146,10 @@ test-clean: generate-required mkdir -p test/report test-unit: test-clean - ${bash} 'go test -v -cover ./pkg/context/... -run TestUnit.* |& tee test/report/unit.report.log' + ${bash} 'go test -v -cover ./pkg/... -run TestUnit.* |& tee test/report/unit.report.log' test-integration: test-clean - ${bash} 'go test -v -cover ./pkg/context/... -run TestIntegration.* |& tee test/report/integration.report.log' + ${bash} 'go test -v -cover ./pkg/... -run TestIntegration.* |& tee test/report/integration.report.log' test-acceptance: test-clean ${bash} 'go test -v -cover ./internal/app/... -run TestAcceptance.* |& tee test/report/acceptance.report.log' diff --git a/README.md b/README.md index a0a5698..d5d72c5 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ go install github.com/bastean/godo/cmd/godo@latest ### Usage ```bash -godo -h +godo ``` ```text @@ -43,53 +43,91 @@ _ / __ _ / / / __ / / /_ / / / Predefined task runner. -Usage: godo [flags] +Usage: + godo [flags] + godo [command] - -task string - Name of the task to run (required) -``` - -## Package +Available Commands: + completion Generate the autocompletion script for the specified shell + exec Execute a list of tasks from a file + help Help about any command -### Download +Flags: + -h, --help help for godo -```bash -go get github.com/bastean/godo +Use "godo [command] --help" for more information about a command. ``` -### Update +## Tasks -```bash -go get -u github.com/bastean/godo -``` +### Exec -### Usage +Execute a list of tasks from a file, all tasks will be executed following the preset order in the configuration file, if any of the tasks fail, the following tasks will not be executed. -```go -package main +```bash +godo exec -c configs/example.exec.json +``` -import ( - "github.com/bastean/godo" -) +```text +Example tasks started! +Create a file +We will create a file and write something in it +(1/2) mkdir -p ignore +(2/2) bash -c echo "Example" > ignore/example.txt +File created! +Example tasks completed! +``` -func main() { - godo.TODO() +[example.exec.json](configs/example.exec.json) + +```json +{ + "Tasks": [ + { + "Success": "Example tasks started!" + }, + { + "Title": "Create a file", + "Description": "We will create a file and write something in it", + "Commands": [ + { + "Name": "mkdir", + "Args": ["-p", "ignore"] + }, + { + "Name": "bash", + "Args": ["-c", "echo \"Example\" > ignore/example.txt"] + } + ], + "Success": "File created!", + "Error": "File could not be created" + }, + { + "Success": "Example tasks completed!" + } + ] } ``` -## Tasks - -### Run - -- - -### Sync - -- - -### Copy +Basic structure + +```json +{ + "Tasks": [ + { + "Title": "", + "Description": "", + "Commands": [{ "Name": "", "Args": [""] }], + "Success": "", + "Error": "" + } + ] +} +``` -- +- `Success` is only displayed if the task has been successfully completed. +- `Error` is only displayed if an error occurred during the execution of the task. +- All fields in a task are optional. ## First Steps @@ -139,13 +177,7 @@ make test-unit make test-integration ``` -##### Acceptance - -```bash -make test-acceptance -``` - -##### Unit / Integration / Acceptance +##### Unit & Integration ```bash make tests @@ -156,6 +188,7 @@ make tests #### Base - [Go](https://go.dev) +- [Cobra](https://cobra.dev) #### Please see