Comments (4)
@jkxyz Indeed, having just a function to map over the stdout and/or stderr would be the most flexible solution. Just an interceptor basically.
from process.
Just a note that foreman only colors the process name at the beginning of the line. The rest of the output is unmodified.
Would it be sufficient to just have a convenience option like
:process-line-fn (fn [s] (str (termcolor :green "FOO | ") s))
from process.
See discussion here with a potential solution:
from process.
Pasting in my current plain bash solution that I'd like to replace. Essentially, I'm wrapping each line with some stuff.
frontend
and backend
are normal bash functions that cd into the right directory, and run make dev
or something similar.
Perhaps I could delete the whole thing and replace it with a little bb.edn
:)
with_prefix() {
# Usage: with_prefix $APPNAME $COLOR
local NOCOLOR='\033[0m'
awk -v name="$1" -v color="$2" -v nocolor="$NOCOLOR" '{ printf "%s[%s]%s %s\n", color, name, nocolor, $0 }'
}
apps() {
# from https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
#
# Black 0;30 Dark Gray 1;30
# Red 0;31 Light Red 1;31
# Green 0;32 Light Green 1;32
# Brown/Orange 0;33 Yellow 1;33
# Blue 0;34 Light Blue 1;34
# Purple 0;35 Light Purple 1;35
# Cyan 0;36 Light Cyan 1;36
# Light Gray 0;37 White 1;37
local NO_COLOR='\033[0m'
local BLACK='\033[0;30m'
local RED='\033[0;31m'
local GREEN='\033[0;32m'
local BROWN_ORANGE='\033[0;33m'
local BLUE='\033[0;34m'
local PURPLE='\033[0;35m'
local CYAN='\033[0;36m'
local LIGHT_GRAY='\033[0;37m'
local DARK_GRAY='\033[1;30m'
local LIGHT_RED='\033[1;31m'
local LIGHT_GREEN='\033[1;32m'
local YELLOW='\033[1;33m'
local LIGHT_BLUE='\033[1;34m'
local LIGHT_PURPLE='\033[1;35m'
local LIGHT_CYAN='\033[1;36m'
local WHITE='\033[1;37m'
local BLACK='\033[0;30m'
local RED='\033[0;31m'
local GREEN='\033[0;32m'
# If secrets env vars are not set, try to source bash / zsh.
frontend 2> >(with_prefix "frontend" "$RED") 1> >(with_prefix "frontend" "$GREEN") &
backend 2> >(with_prefix "backend" "$RED") 1> >(with_prefix "backend" "$BLUE") &
nats 2> >(with_prefix "nats" "$RED") 1> >(with_prefix "nats" "$LIGHT_CYAN") &
sleep 999999999999
}
from process.
Related Issues (20)
- `pb {:in "foo"}` hangs HOT 2
- Exceptions when AOT compiled with Java 9+ and run with Java 8 HOT 1
- Support `:pre-start-fn` in `babashka.process/exec` HOT 1
- Consider supporting redirecting stderr to stdout HOT 1
- chore: address GitHub Actions warnings HOT 1
- Explore Improving Windows Test Coverage HOT 1
- Explore adding test coverage for `exec` HOT 2
- dev chore: consider breaking up large deftest forms HOT 2
- `exec` does not convert `:env` and `:extra-env` keywords HOT 1
- Single map arg for easier programmatic interop
- Add new `:cmd` `opt` to `exec` HOT 3
- Consider `:dir` when resolving `program` on Windows HOT 5
- Chore: consider moving to deps.edn only HOT 2
- chore: no longer need to use bb snapshot version for tests
- Question: input and output streams reversed? HOT 1
- Output of `fs/list-dir` (i.e. `UnixPath`) cannot be passed as-is to `shell` HOT 1
- Continue doesn't work with (shell) HOT 5
- clojure.pprint/pprint throws an exception when printing babashka.process.Process HOT 5
- Tests: Bump to GraalVM current
- Tests: Bump graal-build-time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from process.