GithubHelp home page GithubHelp logo

slavaganzin / await Goto Github PK

View Code? Open in Web Editor NEW
135.0 4.0 3.0 6.43 MB

28Kb, small memory footprint, single binary that run list of commands in parallel and waits for their termination

License: MIT License

C 74.28% Shell 25.72%
cli wait util bash zsh fish parallel runner async posix

await's Introduction

await

28Kb, small memory footprint, single binary that run list of commands in parallel and waits for their termination

build

install

# recommended way (crossplatform)
eget slavaGanzin/await --to /usr/local/bin/

# nix
nix-shell -p await

# arch
yay -S await

# not recommended, but it works!
curl https://i.jpillora.com/slavaGanzin/await! | bash

completions

It's a single binary distribution, so you need to do it yourself (or download from a release)

# bash
await --autocomplete-bash > ~/.bashrc

#zsh
await --autocomplete-zsh > ~/.zshrc

#fish
await --autocomplete-fish > ~/.config/fish/completions/await.fish

With await you can:

Take action on specific file type changes

await 'stat **.c' --change --forever --exec 'gcc *.c -o await -lpthread'
# you can filter with:
`stat --format '%n %z' **; | grep -v node_modules`

Wait for FAANG to fail

await 'whois facebook.com' \
      'nslookup apple.com' \
      'dig +short amazon.com' \
      'sleep 1 | telnet netflix.com 443 2>/dev/null' \
      'http google.com' --fail

Notify yourself when your site down

await "curl 'https://whatnot.ai' &>/dev/null && echo UP || echo DOWN" \
      --forever --change --exec "ntfy send 'whatnot.ai \1'"

await "stylus --watch --compress --out /home/vganzin/work/whatnot/front /home/vganzin/work/whatnot/front/index.styl" \
      "pug /home/vganzin/work/whatnot/front/index.pug --out /home/vganzin/work/whatnot/front --watch --pretty 2>/dev/null" --forever --stdout --silent

await 'echo -n 10' 'echo -n $RANDOM' 'expr \1 + \2' --exec 'echo \3' --forever --silent

Furiously wait for new iPhone in background process

await 'curl "https://www.apple.com/iphone/" -s | pup ".hero-eyebrow text{}" | grep -v 12' --interval 1000 --change --daemon --exec 'ntfy send "\1"'

Restart database and connect immediately after it become fully functional

sudo systemctl restart redis; await 'socat -u OPEN:/dev/null UNIX-CONNECT:/tmp/redis.sock' --exec 'redis-cli -s /tmp/redis.sock'

--help

await [arguments] commands

# runs list of commands and waits for their termination

OPTIONS:
  --help	#print this help
  --stdout -o	#print stdout of commands
  --silent -V	#do not print spinners and commands
  --fail -f	#waiting commands to fail
  --status -s	#expected status [default: 0]
  --any -a	#terminate if any of command return expected status
  --change -c	#waiting for stdout to change and ignore status codes
  --exec -e	#run some shell command on success;
  --interval -i	#milliseconds between one round of commands [default: 200]
  --forever -F	#do not exit ever
  --service -S	#create systemd user service with same parameters and activate it
  --version -v	#print the version of await
  --autocomplete-fish	#output fish shell autocomplete script
  --autocomplete-bash	#output bash shell autocomplete script
  --autocomplete-zsh	#output zsh shell autocomplete script


NOTES:
# \1, \2 ... \n - will be subtituted with n-th command stdout
# you can use stdout substitution in --exec and in commands itself:
  await 'echo -n 10' 'echo -n $RANDOM' 'expr \1 + \2' --exec 'echo \3' --forever --silent


EXAMPLES:
# action on specific file type changes
 await 'stat **.c' --change --forever --exec 'gcc *.c -o await -lpthread'

# waiting google (or your internet connection) to fail
  await 'curl google.com' --fail

# waiting only google to fail (https://ec.haxx.se/usingcurl/usingcurl-returns)
  await 'curl google.com' --status 7

# waits for redis socket and then connects to
  await 'socat -u OPEN:/dev/null UNIX-CONNECT:/tmp/redis.sock' --exec 'redis-cli -s /tmp/redis.sock'

# lazy version
  await 'ls /tmp/redis.sock'; redis-cli -s /tmp/redis.sock

# daily checking if I am on french reviera. Just in case
  await 'curl https://ipapi.co/json 2>/dev/null | jq .city | grep Nice' --interval 86400

# Yet another server monitor
  await "curl 'https://whatnot.ai' &>/dev/null && echo 'UP' || echo 'DOWN'" --forever --change\
    --exec "ntfy send \'whatnot.ai \1\'"

# waiting for new iPhone in daemon mode
  await 'curl "https://www.apple.com/iphone/" -s | pup ".hero-eyebrow text{}" | grep -v 12'\
 --change --interval 86400 --daemon --exec "ntfy send \1"

await's People

Contributors

slavaganzin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

await's Issues

How can I use it in script with bash functions?

 ╰─λ cat test.sh 
#!/bin/bash
function func {
echo 2
}
await 'echo 1' -e 'func'

 ╰─λ test.sh 
sh: line 1: func: command not found
⣷ echo 1

I've tried to pass function with different approaches, but no result. Is it possible to pass function (without using another scripts.sh files or writing entire commands in await) in my case?

Curl und run will never die

curl https://i.jpillora.com/slavaGanzin/await! | bash
This should never ever be done.
Make it worse, use | sudo bash

Please do not recommend this procedure

Invalid SSL cert on documentation website

Website documentation certificate problem:
https://await-cli.app/

The documentation website gives me an invalid certificate error:

Your connection isn't private
Attackers might be trying to steal your information from await-cli.app (for example, passwords, messages or credit cards).
NET::ERR_CERT_COMMON_NAME_INVALID

Error: No asset for platform darwin-amd64

When I try to install await on my M1 Macbook Pro it returns the following error:

curl https://i.jpillora.com/slavaGanzin/await! | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4581    0  4581    0     0   5812      0 --:--:-- --:--:-- --:--:--  5813
============
Error: No asset for platform darwin-amd64

Availability via package managers

Hi Slava,

I just stumbled over await and it looks great!

It would be great if it would be available via platform independent package managers like Flathub or Snap.
And for OS/X users a brew package would be nice.

This way everybody could profit from automated updates.
Thank you so much! 🙌

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.