Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cotowali/cotowali
A statically typed scripting language that transpile into POSIX sh
https://github.com/cotowali/cotowali
cotowari language programming-language shell-script transpiler
Last synced: 9 days ago
JSON representation
A statically typed scripting language that transpile into POSIX sh
- Host: GitHub
- URL: https://github.com/cotowali/cotowali
- Owner: cotowali
- License: mpl-2.0
- Created: 2021-02-13T22:55:28.000Z (over 3 years ago)
- Default Branch: taika-dev
- Last Pushed: 2023-09-04T23:18:32.000Z (about 1 year ago)
- Last Synced: 2024-04-13T20:55:08.402Z (7 months ago)
- Topics: cotowari, language, programming-language, shell-script, transpiler
- Language: V
- Homepage:
- Size: 3.51 MB
- Stars: 599
- Watchers: 6
- Forks: 9
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-programming-languages - Cotowali - A statically typed scripting language that transpile into POSIX sh (Uncategorized / Uncategorized)
- awesome-v - cotowali - A statically typed scripting language that transpiles into POSIX sh. (Applications / Interpreters/Compilers)
README
# We need financial support to continue development. Please [become a sponsor](https://opencollective.com/cotowali).
## Concepts of Cotowali
- Outputs shell script that is fully compliant with POSIX standards.
- Simple syntax.
- Simple static type system.
- Syntax for shell specific feature like pipe and redirection.## Example
```v
fn fib(n: int): int {
if n < 2 {
return n
}
return fib(n - 1) + fib(n - 2)
}fn int |> twice() |> int {
var n = 0
read(&n)
return n * 2
}assert(fib(6) == 8)
assert((fib(6) |> twice()) == 16)fn ...int |> sum() |> int {
var v: int
var res = 0
while read(&v) {
res += v
}
return res
}fn ...int |> twice_each() |> ...int {
var n: int
while read(&n) {
yield n * 2
}
}assert((seq(3) |> sum()) == 6)
assert((seq(3) |> twice_each() |> sum()) == 12)// Call command by `@command` syntax with pipeline operator
assert(((1, 2) |> @awk('{print $1 + $2}')) == '3')
```[There are more examples](./examples)
## Installation
### Use [Konryu](https://github.com/cotowali/konryu) (cotowali installer written in cotowali)
```sh
curl -sSL https://konryu.cotowali.org | sh
# add to your shell config like .bashrc
export PATH="$HOME/.konryu/bin:$PATH"
eval "$(konryu init)"
```### Build from source
0. Install required tools
- [The V Programming Language](https://github.com/vlang/v)
```sh
git clone https://github.com/vlang/v
cd v
make
```- [zakuro9715/z](https://github.com/zakuro9715/z)
```sh
go install github.com/zakuro9715/z
# or
curl -sSL gobinaries.com/zakuro9715/z | sh
```1. Build
```sh
z build
```2. Install
```sh
sudo z symlink
# or
sudo z install
```## How to use
```sh
# compile
lic examples/add.li# execution
lic examples/add.li | sh
# or
lic run examples/add.li
```## Development
See [docs/development.md](./docs/development.md)
### Docker
```
docker compose run dev
```## Author
[zakuro](https://twitter.com/zakuro9715) <[email protected]>
## Acknowledgements
Cotowali is supported by 2021 Exploratory IT Human Resources Project ([The MITOU Program](https://www.ipa.go.jp/english/humandev/third.html) by IPA: Information-technology Promotion Agency, Japan.