Ph0enixKM / Amber

💎 Amber the programming language compiled to bash
https://amber-lang.com
GNU General Public License v3.0
3.5k stars 67 forks source link

[Feature] Commands subset/ORM-like #178

Open Mte90 opened 2 weeks ago

Mte90 commented 2 weeks ago

User can create kind of libraries as wrapper to most common commands and many of them can be shipped by Amber natively.

As example ffmpeg, youtube-dl or find to be able to generate commands automatically without using pure Bash.

An example:

find "$1" -type f ( -iname *.mp3 -o -iname *.flac ) -print0

This can generated with find()->file()->ext(['mp3', 'flac'])->print()

In this way Amber can generate a command that works like everywhere (some GNU commands on OSX are different like sed) and the user write more amber then bash, otherwise there is no useful reason to use Amber.

I can call it like a ORM or CliRM.

Ph0enixKM commented 2 weeks ago

So you propose to create a query parser inside of Amber? I think we could implement macros to Amber so this would be easily programmable. We could also create the whole query language as well but I'm not sure if that's a good idea since it's better to give the programmer building blocks and let them build a library that can do some ORM-like queries as a separate project.

Mte90 commented 2 weeks ago

I think that for some commands can be helpful to have them natively and others instead that are external, like contrib-commands.

As example the GNU commands like mv/cd/ls/find/cat/mkdir etc should be native in the language.

In this way this can be a language and you don't need tons of $command$ in your amber because at that point I can write more fast in bash.

Take this example: https://github.com/Mte90/My-Scripts/blob/master/dev/lsp-installer/install.ab

Probably can simplified with some functions to avoid to repeat them but bash scripts are full of this commands so a way to write more easily is not bad.

Mte90 commented 2 weeks ago

Looking at the docs there is no way right now to write a Class but for something like that can be useful in the language itself.