Last active
May 10, 2021 02:18
-
-
Save soasme/bd4f906c8106941cb56c892b8b3bba7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An idea of a new scripting language that focuses on glueing system commands. | |
# single line command | |
$ echo hello world | |
# multi-lines command | |
$( | |
python myscript.py | |
&& echo "done" | |
) | |
# get stdout from command and do further processing | |
branch =$ git branch -—show-current | |
$ dep deploy -—branch=${branch} | |
branch =$( | |
git branch --show-current | |
) | |
$ dep deploy --branch=${branch} | |
# the further processing can be some sophisticated scripts. | |
files =$ find -name '*_test\.py' | |
for file in files.splitlines() { | |
$ python ${file} | |
} | |
# pipe works | |
$ cat package.json | grep name | |
# type casting make it more robust. | |
count =$ ls -1 | wc -l | |
count = int(count) | |
print("files count: ${count}") | |
# array mapping. | |
hosts = ['h1', 'h2'] | |
hosts.map(host => { | |
$ rsync -azP ./src ${host}:/var/www | |
}) | |
# handle errors. | |
try { | |
$ mkdir /tmp/newdir | |
$ touch /tmp/newdir/newfile | |
$ rmdir /tmp/newdir | |
} catch (e) { | |
print("exit code: ${e.exit_code}") | |
print("error: ${e.stderr}") | |
} | |
# module strutils can manipulate string easier. | |
import strutils | |
print(join(host, ",")) | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment