Examples
Hello World
Create a file named hello-world.mel, and write this code:
#!/usr/bin/env melodium
#! name = hello_world
#! version = 0.1.0
#! require = std:0.10.*
use std/engine/util::startup
use std/engine/log::logInfoMessage
treatment main() {
startup()
logInfoMessage(message = "Hello World!")
startup.trigger -> logInfoMessage.trigger
}
Then run it using melodium run hello-world.mel.
$ melodium run hello-world.mel
[2012-12-21T01:32:45.678Z] info: info: Hello World!Hello World (as project)
Create raw project using melodium new hello-world.
$ melodium new hello-world
success: program 'hello_world' created in 'hello-world'hello-world
├── Compo.toml
└── lib-root.melIn lib-root.mel file, put the following code:
use std/engine/util::startup
use std/engine/log::logInfoMessage
treatment main() {
startup()
logInfoMessage(message = "Hello World!")
startup.trigger -> logInfoMessage.trigger
}In Compo.toml, add the entries:
[entrypoints]
main = "hello_world::main"Run it with melodium run hello-world/Compo.toml:
$ melodium run hello-world/Compo.toml
[2012-12-21T01:32:45.678Z] info: info: Hello World!Download
Create raw project using melodium new download.
$ melodium new download
success: program 'download' created in 'download'In lib-root.mel file, put the following code:
use fs/local::writeLocal
use http/client/util::get
use std/engine/util::startup
use std/engine/log::logError
treatment download(url: string, file: string)
{
startup()
get(url=url)
writeLocal(path=file)
logError()
startup.trigger -> get.trigger,data -> writeLocal.data
get.error --------> logError.message
}
In Compo.toml, add the entries:
[dependencies]
std = "^0.10.0"
fs = "^0.10.0"
http = "^0.10.0"
[entrypoints]
main = "download::download"Run it with melodium run download/Compo.toml --url https://melodium.tech/img/voyage.jpeg --file nantes.jpeg
More Examples
Note
More examples for different applications can be found on the playground of Cadence.CI.