All Projects â†’ coderofsalvation â†’ Powscript

coderofsalvation / Powscript

Licence: other
transpiler written in bash: painless shellscript, indentbased, coffee for the shell with hipster-sparkles v1 BETA LANDED 🎉🎉🎉🎉 thanks fcard!

Programming Languages

shell
77523 projects
coffeescript
4710 projects
bash
514 projects

Projects that are alternatives of or similar to Powscript

Nimporter
Compile Nim Extensions for Python On Import!
Stars: ✭ 474 (+388.66%)
Mutual labels:  transpiler
Ts2c
Convert Javascript/TypeScript to C
Stars: ✭ 878 (+805.15%)
Mutual labels:  transpiler
Transpyle
HPC-oriented transpiler for C, C++, Cython, Fortran, OpenCL and Python.
Stars: ✭ 90 (-7.22%)
Mutual labels:  transpiler
Pseudo
transpile algorithms/libs to idiomatic JS, Go, C#, Ruby
Stars: ✭ 654 (+574.23%)
Mutual labels:  transpiler
Pas2dart
Object Pascal (Free Pascal 3, Delphi 2007) to Dart (2.5) transpiler
Stars: ✭ 16 (-83.51%)
Mutual labels:  transpiler
Elchemy
Write Elixir code using statically-typed Elm-like syntax (compatible with Elm tooling)
Stars: ✭ 1,080 (+1013.4%)
Mutual labels:  transpiler
Haxe
Haxe - The Cross-Platform Toolkit
Stars: ✭ 4,665 (+4709.28%)
Mutual labels:  transpiler
Evm2wasm
[ORPHANED] Transcompiles EVM code to eWASM
Stars: ✭ 96 (-1.03%)
Mutual labels:  transpiler
Prolog Target Js
Simple Prolog to JS transpiler
Stars: ✭ 19 (-80.41%)
Mutual labels:  transpiler
Get Schwifty
Get Schwifty is a self-hosted Swift transpiler and was originally build for my WWDC scholarship application.
Stars: ✭ 89 (-8.25%)
Mutual labels:  transpiler
Onelang
Stars: ✭ 725 (+647.42%)
Mutual labels:  transpiler
Typescripttolua
Typescript to lua transpiler. https://typescripttolua.github.io/
Stars: ✭ 783 (+707.22%)
Mutual labels:  transpiler
Jsweet
A Java to JavaScript transpiler.
Stars: ✭ 1,167 (+1103.09%)
Mutual labels:  transpiler
Rapydscript
Python-inspired, decluttered JavaScript
Stars: ✭ 560 (+477.32%)
Mutual labels:  transpiler
Pysimpleguidesigner
Desinger for PySimpleGUI
Stars: ✭ 95 (-2.06%)
Mutual labels:  transpiler
Ruby Next
Ruby Next makes modern Ruby code run in older versions and alternative implementations
Stars: ✭ 460 (+374.23%)
Mutual labels:  transpiler
Qooxdoo Compiler
Compiler for Qooxdoo, 100% javascript
Stars: ✭ 32 (-67.01%)
Mutual labels:  transpiler
Cs2x
Transpiles a C# subset to non .NET languages and runtimes. (Powered by Roslyn)
Stars: ✭ 97 (+0%)
Mutual labels:  transpiler
Fetlang
Fetish-themed programming language
Stars: ✭ 1,337 (+1278.35%)
Mutual labels:  transpiler
Cessie
Transpile your CSS bundle to support CSS variables, calc, and future CSS for legacy browsers.
Stars: ✭ 81 (-16.49%)
Mutual labels:  transpiler

Travis build status

write shellscript in a powful way!

Usage

$ wget "https://raw.githubusercontent.com/coderofsalvation/powscript/master/powscript" -O /usr/local/bin/powscript && chmod 755 /usr/local/bin/powscript
$ powscript myscript.pow                          # run directly
$ powscript -c myscript.pow > myscript            # output bashscript
$ powscript -c --to sh myscript.pow > myscript.sh # output sh-script (experimental)

Wiki

Example

#!/usr/bin/env powscript
require_cmd 'echo'
require_env 'TERM'

error(msg exitcode)
  echo "error: $msg"
  if set? $exitcode
    exit $exitcode

run(@args -- foo)
  if empty? foo
    error "please pass --foo <string>" 1
  echo $args[@] "$foo universe!!"
  echo "HOME=$HOME"

run [email protected]

Output:

$ powscript -c foo.pow -o foo.bash
$ ./foo.bash hello --foo powful
hello powful universe!
HOME=/home/yourusername

Check a json example here and here for more examples

Features

Examples

Interactive mode (experimental)

Put this line in your .inputrc:

"\C-p" "powscript --interactive\n"

Then hitting ctrl-p in your console will enter powscript mode:

hit ctrl-c to exit powscript, type 'edit' to launch editor, and 'help' for help
> each(line)
>   echo line=$line
> run()
>   tail -2 ~/.kanban.csv | mappipe each
> run
line=1,foo,bar,flop
line=2,foo2,bar2,flop2
>

POSIX /bin/sh compatibility

Powscript can produce 'kindof' POSIX /bin/sh-compatible output by removing bashisms, by introducing the --sh flag:

$ powscript --c foo.pow -o foo.bash
$ powscript --to sh --c foo.pow -o foo.sh

This however, is experimental, as well as the standalone bash2sh converter:

$ cat foo.bash | powscript --to sh  > foo.sh

NOTE: remove bashisms manually using docs/tools like bashism guide or checkbashisms The general rule for POSIX sh-output is: don't write bashfeatures in powscript

Debug your powscript syntax

See FAQ

OSX users

OSX might protest since it isn't quite GNU focused. Please run these commands after installing:

$ brew install bash
$ brew install coreutils gnu-sed grep gawk --default-names
$ echo 'export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH' >> ~/.bashrc
$ sed -i 's|#!/bin/bash|#!/usr/local/bin/bash|g' powscript

Live expansion inside editor

HINT: use live expansion inside vim. Put the lines below in .vimrc and hit 'p>' in normal/visual mode to expand powscript to bash

vmap p> :!PIPE=2 powscript -c<CR>
nmap p> ggVG:!PIPE=2 powscript -c<CR>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].