Creating a new package
Let's say we want to create a new Keli package named MyPackage , we can achieve this by typing the following command:
1
keli new-package MyPackage
Copied!
After typing this command, you should see some output message like this:
1
Creating package `MyPackage`
2
Creating _src folder
3
Initializing purse.json
4
Creating _test folder
5
Creating README file
6
Creating LICENSE file
7
Creating .gitignore file
8
Initialized empty Git repository in /home/hou32hou/Repos/MyPackage/.git/
9
10
Staging and commiting initial files
11
12
==== Package successfully created! ====
13
14
Type the following command to go into your package:
15
16
cd MyPackage
17
Copied!
Then, type the following command to go into the MyPackage directory:
1
cd MyPackage
Copied!
After that, we need to add corelib as dependencies, we can do that by typing:
1
keli add-dependency https://github.com/KeliLanguage/corelib.git 0.0.1-e
Copied!
Now, open the folders of MyPackage in Visual Studio Code by typing:
1
code .
Copied!
When you open the file trees in VSCode, you will notice that there are the _src folder, this is the folder where you will store your Keli source files for our package MyPackage .
You might have notice that there is nothing inside the _src folder. To try things out, let us create a file named MyPackageDemo.keli inside the _src folder.
Then, paste in the following contents into MyPackageDemo.keli :
1
= module.import("../KeliLanguage.corelib.0.0.1-e/Boolean.keli")
2
= module.import("../KeliLanguage.corelib.0.0.1-e/Math.keli")
3
= module.import("../KeliLanguage.corelib.0.0.1-e/String.keli")
4
= module.import("../KeliLanguage.corelib.0.0.1-e/List.keli")
5
6
= "Hello world".replace("world") with("Keli!")
7
8
= 123.+(456).*(789)
9
10
= [1,2,3,4,5].toList.select(.*(2))
11
12
= [1,2,3,4,5].toList.where(.>(3))
Copied!
Now, open MyPackageDemo.keli in VSCode.
Then, click on the Run this Keli Program button located at the bottom of VSCode (note that this will only be true if you already install the Keli VSCode Extension).
After that, you should see the following:
Output of each expression is shown after pressing [Run this Keli program]
That's all. Thank you for reading. Enjoy!
Last modified 2yr ago
Copy link