You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple command to run scripts/commands in multiple directories in sequence. Spread is designed to do one thing and do it well. It is a simpler alternative to GNU Parallel.
2
4
3
-
A simple command to help running scripts/commands in multiple subdirectories. Spread is designed to do one thing and do it well. It is a simpler alternative to GNU Parallel.
4
5
5
6
## Installation
6
7
@@ -16,12 +17,14 @@ Using go:
16
17
$ go get github.com/tfogo/spread
17
18
```
18
19
20
+
19
21
## Usage
20
22
21
23
```
22
-
$ spread <commands>
24
+
$ spread [command] [directories...]
23
25
```
24
26
27
+
25
28
### Example
26
29
27
30
Say we're in a directory `A` with three subdirectories which all have `README.md` files:
@@ -36,49 +39,55 @@ A
36
39
└── README.md
37
40
```
38
41
39
-
To append some text to each `README.md` file at once, run:
42
+
To append some text to each `README.md` file, run:
40
43
41
44
```
42
45
$ spread 'echo text >> README.md'
43
46
```
44
47
45
-
The arguments to `spread`are run in each subdirectory.
48
+
The first argument to `spread`is the command to run in each subdirectory.
46
49
47
-
### Running multiple commands
48
50
49
-
Spread will run commands in sequence on each subdirectory. If any command in the sequence fails, the rest of the commands will not run. Therefore, you can run commands based on the exit code of previous commands. For example, running tests:
51
+
### Specifying directories
52
+
53
+
By default `spread` will run the command in all the subdirectories of the present working directory. You can specify directories in which to run the command by adding further arguments:
50
54
51
55
```
52
-
$ spread 'npm test' 'git push origin master'
56
+
$ spread 'echo text >> README.md' dir1 dir2
53
57
```
54
58
55
-
### Excluding subdirectories
56
59
57
-
To exclude subdirectories, use `-x`:
60
+
### Running multiple commands
61
+
62
+
A common use is chaining multiple commands based on the exit code of previous commands using `&&`. For example, running tests then pushing to a git remote:
58
63
59
64
```
60
-
$ spread -x dir1 'echo text >> README.md'
65
+
$ spread 'npm test && git push origin master'
61
66
```
62
67
63
-
`-x` can take a glob such as `dir{1,2}`.
64
68
65
-
## Reference
69
+
### No-ops
70
+
71
+
If you need to run a no-op, use an empty string, a colon, or `true` as the first argument.
help, h Shows a list of commands or help for one command
82
+
To view the help, run `spread` without any arguments or pass the `--help` or `-h` flags.
79
83
80
-
GLOBAL OPTIONS:
81
-
--exclude value, -x value Glob of directories to exclude
82
-
--help, -h show help
83
-
--version, -v print the version
84
-
```
84
+
85
+
## License (MIT)
86
+
87
+
Copyright 2018 Tim Fogarty
88
+
89
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
90
+
91
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
92
+
93
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copy file name to clipboardExpand all lines: spread.go
+48-28Lines changed: 48 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ import (
13
13
funcmain() {
14
14
app:=cli.NewApp()
15
15
app.Name="spread"
16
-
app.Usage="Run scripts and commands in multiple directories at once. \n\nWEBSITE: \n\n github.com/tfogo/spread\n\nDESCRIPTION:\n\nSpread is designed to do one thing and do it well. It is a simpler alternative to GNU Parallel. Spread will run commands in sequence on each subdirectory. If any command in the sequence fails, the rest of the commands will not run. Therefore, you can run commands based on the exit code of previous commands. \n\nEXAMPLES: \n\n spread 'npm test' 'git push origin master'"
app.Usage="Run scripts and commands in multiple directories. \n\nWEBSITE: \n\n github.com/tfogo/spread\n\nDESCRIPTION:\n\nThe first argument to spread is the command that will be run. By default, spread will run the command in all the subdirectories of the present working directory. Add a list of files as arguments after the command to specify the directories in which the command should run.\n\nEXAMPLES: \n\n spread 'npm test && git push origin master'\n spread ls dir1 dir2 dir3"
0 commit comments