1
0
mirror of https://github.com/go-task/task.git synced 2024-12-12 10:45:49 +02:00
Commit Graph

300 Commits

Author SHA1 Message Date
Pete Davison
376a6182eb feat: aliases
feat: add aliases to --list and --list-all flags

feat: add aliases to --summary

feat: enable aliases for included tasks

tests: added alias unit tests
2022-10-07 11:11:14 +00:00
Pete Davison
8ce1782380 feat: add coloured output to --list, --list-all and --summary flags
feat: add coloured output to --list and --list-all

feat: add coloured output to --summary

chore: update colors

refactor: better consistency in writer calls in printTasks

feat: subtasks are printed green in --summary
2022-10-07 09:54:17 +00:00
Andrey Nering
f45dd11e53 Add ROOT_DIR and TASKFILE_DIR special variables
Closes #215
2022-09-03 18:14:54 -03:00
Andrey Nering
beb927f7b4
Merge pull request #831 from ilewin/check_path_for_symlinks_issue_826
Attempt to fix Task not following symlinks
2022-08-23 18:38:17 -03:00
ilewin
2a67499f12 Issue #826. Replaced zglob.Glob func with GlobFollowSymlinks to evaluate symlinks 2022-08-23 18:25:11 +02:00
Oleg Kovalov
b08eac58e9
Fix go-critic suggestions 2022-08-17 19:37:58 +02:00
Andrey Nering
c4e10ef0aa Refactor: Add SmartJoin to handle IsAbs automatically 2022-08-06 18:19:07 -03:00
Andrey Nering
fedb68cde7 Allow override the .task dir location with the TASK_TEMP_DIR env 2022-07-08 14:40:10 -03:00
Alexander Mancevice
f54fef7e7b Allow users to override colors using environment variables
Closes #568
Closes #792
2022-07-06 11:46:59 -03:00
Andrey Nering
e36c77aaf3 Fix bug with STDOUT and STDERR in the "group" output mode
Took the oportunity to refactor a bit how we handle closing of the streams.

Fixes #779
2022-07-06 10:45:07 -03:00
Andrey Nering
7989f73f06 Fix behavior of interrupt (SIGINT, SIGTERM) signals
Task will now give time for the processes running to do cleanup work

Ref #458
Ref #479
Fixes #728

Co-authored-by: Marco Molteni <marco.molteni@pix4d.com>
Co-authored-by: aliculPix4D <aleksandar.licul_ext@pix4d.com>
2022-06-11 22:43:22 -03:00
Andrey Nering
d450444596 Temporarily revert #479 2022-05-22 16:54:35 -03:00
Andrey Nering
9e1d4e7855 Add golangci-lint
https://golangci-lint.run/
2022-05-15 21:30:07 -03:00
aliculPix4D
367c0b38a6 fix: remove redundant newline (linter error) 2022-05-13 17:36:52 -07:00
Marco Molteni
22dfc1e265 execext.RunCommand: fix: do not pass a cancellable context to mvdan.cc/sh
We used to pass to mvdan.cc/sh/interp.Runner a context that was cancelled on
reception of a OS signal. This caused the Runner to terminate the subprocess
abruptly.

The correct behavior instead is for us to completely ignore the signal and let
the subprocess deal with it. If the subprocess doesn't handle the signal, it
will be terminated. If the subprocess does handle the signal, it knows better
than us wether it wants to cleanup and terminate or do something different.

So now we pass an empty context just to make the API of interp.Runner happy

Fixes go-task/task/#458
2022-05-13 17:36:52 -07:00
Marco Molteni
bffb6e1a07 add regression test for SIGINT behavior
See go-task/task/#458

Helper (sleepit) and test code based on https://github.com/marco-m/timeit
2022-05-13 17:36:52 -07:00
Andrey Nering
1acd59c7d6 Replace \r\n on Windows as we do for \n on Linux
Closes #717
2022-05-08 17:37:24 -03:00
Andrey Nering
de09843467 Improvements + CHANGELOG for #677 2022-03-19 18:41:03 -03:00
Andrey Nering
b323531dd5 Improvements and CHANGELOG for #651 2022-02-19 19:31:27 -03:00
Jay Anslow
74f5cf8f29
Add support for begin/end messages with grouped output
Fixes #647

This allows CI systems that support grouping (such as with [GitHub Actions's `::group::` command](https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#grouping-log-lines) and [Azure Devops](https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#formatting-commands)) to collapse all of the logs for a single task, to improve readability of logs

## Example

The following Taskfile

```
# Taskfile.yml
version: 3
output:
  group:
    begin: "::group::{{ .TASK }}"
    end: "::endgroup::"
tasks:
  default:
    cmds:
      - "echo 'Hello, World!'"
```

Results in the following output
```bash
$ task
task: [default] echo 'Hello, World!'
::group::default
Hello, World!
::endgroup::
```

See [this GitHub Actions job](https://github.com/janslow/task/runs/4811059609?check_suite_focus=true) for a full example

<img width="771" alt="image" src="https://user-images.githubusercontent.com/1253367/149429832-6cb0c1b5-0758-442e-9375-c4daa65771bc.png">
<img width="394" alt="image" src="https://user-images.githubusercontent.com/1253367/149429851-1d5d2ab5-9095-4795-9b57-f91750720d40.png">
2022-01-14 00:22:14 +00:00
Andrey Nering
f945fa60d9 Merge branch 'bugfix/issue-481-dynamic-vars-broken' of https://github.com/masaushi/task into masaushi-bugfix/issue-481-dynamic-vars-broken 2022-01-04 17:39:14 -03:00
nichady
9a5d49774e replace usages of ioutil with io and os 2021-12-20 20:00:34 -06:00
Andrey Nering
3cfe21af58 Add shellQuote template function 2021-10-02 18:29:07 -03:00
masaushi
93dcb20e12 fix error in evaluating dynamic variables with newly created directory 2021-09-26 22:30:32 +09:00
Ross Hammermeister
2da38a5bdc Cleaning up the run code 2021-07-31 19:36:40 -03:00
Ross Hammermeister
97c85e39c3 Only run task once for #53 2021-07-31 19:36:40 -03:00
Andrey Nering
824b0c0132 Improve error message 2021-07-10 19:33:36 -03:00
Nicolas Fouché
08265ed1d7 Allow vars in dotenv paths, including environment variables
Closes #453
Closes #434
Ref #433

Co-authored-by: Andrey Nering <andrey@nering.com.br>
2021-06-05 16:00:19 -03:00
Andrey Nering
4e1f2ad017 Enforce NO_COLOR=1 on tests to make sure it passes
Closes #459
Fixes #480
Ref #343
Ref fatih/color#137
2021-05-30 22:48:48 -03:00
Landon Dyck
b825ad6a12 use status.Glob for watch globbing 2021-05-08 15:02:08 -05:00
Andrey Nering
e6c4706b73 Add support for delegating CLI arguments with "--" and a special CLI_ARGS variable
Closes #327
2021-03-20 11:58:45 -03:00
Andrey Nering
bf6d0c0a74 Improve performance of --list and --summary flags
Closes #332
2021-01-12 12:03:04 -03:00
Andrey Nering
e086b654aa Environment from .env file should be available as variables
Fixes #379
2021-01-12 11:11:40 -03:00
Andrey Nering
4afc0e8ed0 Fixed some bugs and regressions regarding dynamic variables and directories
Closes #426
2021-01-09 13:51:06 -03:00
Andrey Nering
141b377b4e Partly revert 59d2733b88
Keep the old behavior on v2
2021-01-09 10:55:18 -03:00
Andrey Nering
83d25bfa00 Refactor: Fix import order
It should be: stdlib > libs > app
2021-01-07 11:48:33 -03:00
Andrey Nering
ec4cd5ed48 Fix .task directory location
Closes #247
2021-01-07 11:36:09 -03:00
Andrey Nering
59d2733b88 Make dynamic variables run on the right directory
It was always running in the main Taskfile dir, even when the variable was
declared in an included taskfile in another directory or when task had a
custom dir.

Closes #384
2021-01-07 11:26:11 -03:00
Andrey Nering
2d52485d7b Watch: Clear vars cache between runs
Closes #365
2021-01-05 11:19:34 -03:00
Andrey Nering
22fd74846d Use interp.Params("-e") intead of running "set -e" manually
This is an improvement for ac8e344173
2021-01-01 17:32:42 -03:00
Andrey Nering
ac8e344173 Run "set -e" automatically for every command
Without this, multiline command strings won't always exit when they fail.

Closes #403
2020-12-27 17:15:12 -03:00
Andrey Nering
16fad60833 execext: Small refactor 2020-12-27 16:51:00 -03:00
Damian Szulc
47dd9b5a03 Move args and taskfile packages to root directory 2020-08-19 10:59:58 +02:00
Andrey Nering
6ff3c9015b On v3, treat all CLI variables as global variables
Closes #336
Ref #341

Co-authored-by: Egor Kovetskiy <e.kovetskiy@gmail.com>
2020-08-16 21:27:11 -03:00
Andrey Nering
fb72b46a3c github.com/go-task/task/v2 -> github.com/go-task/task/v3 2020-08-16 15:48:19 -03:00
Andrey Nering
eab14b6c49 Some improvements to #356 2020-08-15 19:13:30 -03:00
Chris Garrett
8b962fb8e8 #324 implement dotenv 2020-08-03 16:18:38 -06:00
Adam Wasila
9f83311931 Add label field to task definition
Label is an alternative name for task that replace it when printed in following context eg.:

- log: when given task is up to date and is skipped from execution
- log: when given task is NOT up to date (`--status` command)
- in `--summary` and `--list` commands output
2020-06-14 13:42:20 +02:00
Andrey Nering
f4f6efa547 Skip cleanup if task doesn't have any sources listed
Ref #333
2020-05-31 15:48:23 -03:00
Andrey Nering
9f0f18c5c4 v3: Allow interpolation on "includes"
The idea is to allow manual inclusion of a OS-dependant Taskfile, since it's
not automatically included anymore.
2020-05-17 16:03:03 -03:00
Andrey Nering
191c34c9c4 v3: Do not include Taskfile_{{OS}}.yml automatically 2020-05-17 15:42:27 -03:00
Andrey Nering
68ce8642b1 Create v3 compiler which respects declaration order of variables
Also, fix "<no value>" been printed when a non-existing variable is printed.
2020-05-16 15:46:07 -03:00
Andrey Nering
cbb12b29bd v3: Fix bug where global vars were not being considered 2020-04-05 11:16:27 -03:00
Andrey Nering
6ed30f1add Refactor variables: Keep order of declaration
This shouldn't have any behavior changes for now. This is a code
refactor that should allow us to do further improvements on how
variables are handled, specially regarding respecting the declaration
order in Taskfiles, which should make it easier for the users.

Initial work on #218
2020-04-05 11:16:14 -03:00
Andrey Nering
a044c41c66 Upgrade github.com/go-yaml/yaml to v3 2020-03-28 11:27:49 -03:00
Andrey Nering
acfbbaa549 Merge branch 'master' into v3 2020-03-28 10:48:49 -03:00
Evgeny Abramovich
0acb911d6a Fixed absolute path resolving for included tasksfile 2020-02-15 18:07:09 +03:00
Evgeny Abramovich
17ad7060b3 Added version validation and updated tests 2020-02-15 17:24:06 +03:00
Evgeny Abramovich
f38ba7fcd3 Removed automatic inclusion of Taskfiles by OS and update tests 2020-02-15 17:19:09 +03:00
Evgeny Abramovich
a3464068bd Rename TaskFile to Taskfile 2020-02-12 10:42:00 +03:00
Evgeny Abramovich
8ff81562d2 Added os-related files for included taskfiles 2020-01-29 10:39:43 +03:00
Evgeny Abramovich
7a8142ed92 Added included taskfile directory resolving 2020-01-29 10:39:26 +03:00
Evgeny Abramovich
eaba1b9cc8 Added structure for storage information about included tasks 2020-01-29 10:02:22 +03:00
Paul Varache
7453e688fd Compile tasks before printing help or summary (Closes #276) 2020-01-26 21:32:20 +00:00
Andrey Nering
15338ecb18 Merge branch 'master' into v3 2019-12-07 22:04:16 -03:00
Andrey Nering
4bdfe64afb Add hability silent all tasks
By add `silent: true` at the root of the Taskfile.
2019-12-07 21:44:09 -03:00
Andrey Nering
b7b752b92f Allow shorter syntax for tasks with default configuration
Closes #194
Closes #240

Co-authored-by: Jaedle <dennis.jekubczyk@gmail.com>
2019-12-07 21:28:02 -03:00
Andrey Nering
b7bcd204b4 go fmt internal/taskfile/task.go 2019-12-07 20:09:16 -03:00
Andrey Nering
7373639f57 Expose .TASK variable with the task name
Closes #252
2019-12-07 19:43:10 -03:00
Andrey Nering
d718527a1f Merge branch 'master' into v3 2019-12-07 16:54:29 -03:00
Andrey Nering
48add0f293 Write more args tests 2019-12-07 16:48:23 -03:00
Andrey Nering
a4685229c9 Fix bug of Task not executing the "default" task
When global vars were informed using the CLI.

I took the oportunity to move this logic to the proper package and
write a test.
2019-12-07 16:20:36 -03:00
Andrey Nering
1d3b93d88d Remove bold from colored text 2019-11-24 21:07:12 -03:00
Andrey Nering
62752ba7e1 Merge branch 'master' into v3 2019-11-24 21:02:33 -03:00
Andrey Nering
09d5d802d0 Upgrade mvdan.cc/sh to v3.0.0-beta1 2019-11-24 19:17:09 -03:00
Andrey Nering
5acdb041a9 Merge branch 'master' into v3 2019-11-02 22:16:44 -03:00
Andrey Nering
9a8442c946 Update some tools and fix error and calling exit 0
Fixes #251
2019-10-27 18:14:22 -03:00
Andrey Nering
1a28e5e0d4 Few code improvements on #216 2019-09-14 17:54:41 -03:00
Andrey Nering
884cd0d636 Merge branch 'CypherpunkArmory-report-timestamp-to-status' into v3 2019-09-14 17:18:42 -03:00
Andrey Nering
78595fba0b Make "checksum" the default method in v3 2019-09-08 22:51:56 -03:00
Andrey Nering
8020284b12 Add global method: option to set default method 2019-09-08 22:51:14 -03:00
Andrey Nering
d6a49da870 Merge branch 'master' into v3 2019-09-08 22:12:02 -03:00
Andrey Nering
0e1d8a72e6 Revert "Ensure the $HOME env is being set on Windows"
This reverts commit 52028fc3bc.
2019-09-08 21:56:23 -03:00
Andrey Nering
bbdd698869 Upgrade mvdan.cc/sh to use edge 2019-09-08 21:55:02 -03:00
Andrey Nering
7138785500 Merge branch 'master' into v3 2019-09-07 14:44:21 -03:00
Andrey Nering
d8005b4cf6 Fix typo 2019-09-07 14:32:02 -03:00
Andrey Nering
52028fc3bc Ensure the $HOME env is being set on Windows 2019-09-07 14:29:13 -03:00
Andrey Nering
1a33f9168b Merge branch 'report-timestamp-to-status' of https://github.com/CypherpunkArmory/task into CypherpunkArmory-report-timestamp-to-status 2019-09-01 21:44:23 -03:00
Andrey Nering
1b8998e7a2
Merge pull request #237 from jaedle/v3
Remove all code related support of version 1
2019-08-25 18:11:47 -03:00
Andrey Nering
dc8fb79759 Merge branch 'master' into v3 2019-08-25 18:05:40 -03:00
Stephen Prater
6b0935d6cf Fix tests 2019-08-25 13:47:29 -07:00
Stephen Prater
d1183ce272 Merge branch 'master' into report-timestamp-to-status
* master:
  Update CHANGELOG
  Small improvements to #228
  Fix a typo
  Fix Checksum.IsUpToDate
  Remove directory check
  Update glob.go
  Separate error handlings for readability
  Re-run the task if generated files do not exist
2019-08-25 13:46:02 -07:00
Stephen Prater
a1aec8178a Export Time Struct to Template 2019-08-25 13:36:48 -07:00
Andrey Nering
0d9fdbaac1 Small improvements to #228 2019-08-25 16:32:25 -03:00
Andrey Nering
f5cd3eab9e
Merge pull request #228 from topecongiro/checksum-look-for-generated
Re-run the task if generated files do not exist
2019-08-25 16:32:03 -03:00
Stephen Prater
cb6fe4bb59 Merge remote-tracking branch 'upstream/v3' into report-timestamp-to-status
* upstream/v3:
  v3.0.0-preview1
  Update v3 changelog
  Only have colored output on v3
  Add --color=false flag to disable colored output
  Update documentation about sprig
  Update CHANGELOG
  Migrate from sprig to slim-sprig
  Fix build after merging master
  Use colors for some output messages
2019-08-25 10:33:13 -07:00
Stephen Prater
db36bc67f1 Changes per feedback 2019-08-25 10:30:00 -07:00
Stephen Prater
1ee684b7c0 Expose timestamp and checksum to status 2019-08-25 09:39:39 -07:00
jaedle
93005512b4 cleanp taskfile reader 2019-08-24 06:28:12 +02:00
Seiichi Uchida
8987cd64a0 Fix a typo 2019-08-21 13:42:19 +09:00
Seiichi Uchida
fac51dcf03 Fix Checksum.IsUpToDate
- Check whether generates exist after the creation of checksum file
- Check whether generates exist if only the user specified generates fields
- Check for each generates field instead of taking it as a whole
2019-08-21 13:35:16 +09:00
Seiichi Uchida
01101a4c9b Remove directory check 2019-08-21 13:34:58 +09:00
Seiichi Uchida
d561e40817 Update glob.go
- Rename glob() to globs()
- Add glob() which handles a single glob pattern
- Change glob() and globs() so that they do not return directoreis
2019-08-21 13:33:12 +09:00
Seiichi Uchida
0cb298ebdf Separate error handlings for readability 2019-08-19 13:00:10 +09:00
jaedle
0f385f9f4e remove v1 2019-08-18 17:37:21 +02:00
Andrey Nering
d5a791b470 Merge branch 'master' into v3 2019-08-11 23:03:58 -03:00
Andrey Nering
955359b073 Fix nil panic bug when assigning global var and no var is declared on the Taskfile
Closes #229
Ref #234
2019-08-10 19:38:57 -03:00
Seiichi Uchida
26e0c0887a Re-run the task if generated files do not exist 2019-08-01 13:08:53 +09:00
Andrey Nering
d970e93507 Add --taskfile flag (alias -t) to allow running another Taskfile
Closes #221
2019-07-21 10:57:04 -03:00
Andrey Nering
0e575e9c25 Add --color=false flag to disable colored output 2019-07-07 14:13:53 -03:00
Andrey Nering
fb23ba9878 Merge branch 'v3' into colored-output 2019-07-07 14:04:12 -03:00
Andrey Nering
bd5fb9be03 Migrate from sprig to slim-sprig 2019-06-22 22:17:24 -03:00
Andrey Nering
7f082a821d Merge branch 'v3' into colored-output 2019-06-15 22:42:15 -03:00
Andrey Nering
abe0352de9 Fixed some bugs regarding minor version checks on version:
1. I have forgot to update it on recent releases. Seems that most people just
   use round versions since nobody complained.
2. It's too hard to understand how the github.com/Masterminds/semver package
   works, so I just got rid of it and we're now using plain float checks.
2019-06-15 22:39:35 -03:00
Stephen Prater
d1463b3e24 Fix typos per review 2019-06-11 11:46:22 -07:00
Stephen Prater
044d3a0ff9 Remove ignore_errors 2019-05-28 13:02:59 -07:00
Stephen Prater
659cae6a4c
Apply suggestions from code review
Co-Authored-By: Andrey Nering <andrey.nering@gmail.com>
2019-05-28 12:28:29 -07:00
Andrey Nering
8efc38ad82 Use colors for some output messages 2019-05-26 18:36:39 -03:00
Stephen Prater
bd5882f0f0 Add Preconditions to Tasks 2019-05-17 13:51:15 -07:00
Andrey Nering
83d618e1eb Revert "Upgrade to yaml/go-yaml v3"
This reverts commit 8001fb3915.
2019-05-11 11:22:13 -03:00
Andrey Nering
f0768b3af1 Allow setting global variables through the CLI
Closes #192
2019-05-11 11:06:47 -03:00
Andrey Nering
90613220c6 Fixes some bugs relatated to commands output handling
This seems to fix some of the bugs reported by issues like #114 and #190.

Seems that the standard library's os/exec package has some black magic to
detect if a writer is an actual *os.File, and some stuff are handled
differently, then.

Fixes #114
Fixes #190
2019-04-21 16:55:47 -03:00
Andrey Nering
8001fb3915 Upgrade to yaml/go-yaml v3 2019-04-13 17:25:28 -03:00
Kirill Motkov
53d54d1c4a Rewrite if-else chain to switch statement 2019-03-19 14:19:21 +03:00
jaedle
360da29e1f refactoring 2019-03-04 13:04:04 +01:00
jaedle
9cfac1642a rename method for summary/summaries 2019-03-04 13:03:13 +01:00
jaedle
1d783bf6c7 refactoring 2019-03-04 12:47:01 +01:00
jaedle
1025c2e3a1 add unit test for spacing between summaries 2019-03-04 12:46:02 +01:00
jaedle
4fd82ab222 refactoring 2019-03-04 12:28:26 +01:00
jaedle
8eadfc1bf6 refactoring 2019-03-04 12:28:11 +01:00
jaedle
f66edbad50 refactoring 2019-03-04 12:27:10 +01:00
jaedle
c7f17b5319 refactoring 2019-03-04 12:25:42 +01:00
jaedle
7e7e1bccba rearrange imports 2019-03-04 12:04:31 +01:00
jaedle
34f6da86c3 rearrange imports 2019-03-04 12:03:28 +01:00
Andrey Nering
f945cf2343
Update internal/summary/summary_test.go
Co-Authored-By: jaedle <32975714+jaedle@users.noreply.github.com>
2019-03-03 19:45:00 +01:00
Andrey Nering
f5f0e0c376
Update internal/summary/summary.go
Co-Authored-By: jaedle <32975714+jaedle@users.noreply.github.com>
2019-03-03 19:43:57 +01:00
jaedle
2a1571a99e refactoring 2019-02-24 19:14:15 +01:00
jaedle
3f8ee21849 print error messsage if no summary or description present 2019-02-24 18:26:16 +01:00
jaedle
845b88a193 print only task name if summary 2019-02-24 18:20:59 +01:00
jaedle
e252972c7f rename test 2019-02-24 17:29:03 +01:00
jaedle
a9012ebfc5 refactoring 2019-02-24 17:28:06 +01:00
jaedle
5cfd9bbbbd refactoring 2019-02-24 17:25:03 +01:00
jaedle
c82a7240bb print task in command section 2019-02-24 17:23:31 +01:00
jaedle
a4a20d92a4 add unit test for full output 2019-02-24 17:20:29 +01:00
jaedle
890996f595 hides commands keywoard if not present 2019-02-24 17:12:22 +01:00
jaedle
474f27c6d3 add unit test for displaying commands 2019-02-24 17:10:59 +01:00
jaedle
33f3894372 add unit tests for summary 2019-02-24 17:05:37 +01:00
jaedle
24436ac76e refactoring 2019-02-24 16:26:46 +01:00
jaedle
3ee66ef705 remove output to own package 2019-02-24 16:25:27 +01:00
jaedle
d05d418c4c renaming field in taskfile to summary 2019-02-24 15:37:02 +01:00