amber-lang / amber

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

[Feature] Commands subset/ORM-like #178

Open Mte90 opened 4 months ago

Mte90 commented 4 months 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 4 months 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 4 months 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 4 months 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.

b1ek commented 3 months ago

how would you imagine one would define that structure? i mean as in a library that provides that functionality

Mte90 commented 3 months ago

I think like a Class object in any language and that the last method return the whole command generated.