Skip to content

Commit

Permalink
Merge pull request #553 from dictu-lang/develop
Browse files Browse the repository at this point in the history
Release 0.26.0
  • Loading branch information
Jason2605 authored Nov 8, 2022
2 parents 109d93a + c10d9ad commit ef66697
Show file tree
Hide file tree
Showing 59 changed files with 2,031 additions and 79 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ on:
- master

jobs:
check-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Make dictu and run checkTests
run: |
cmake -DCMAKE_BUILD_TYPE=Debug -DDISABLE_HTTP=1 -B ./build
cmake --build ./build
./dictu scripts/checkTests.du ci
test-ubuntu-cmake:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -20,7 +29,7 @@ jobs:
run: |
cmake -DCMAKE_BUILD_TYPE=Debug -DDISABLE_HTTP=1 -B ./build
cmake --build ./build
./dictu tests/runTests.du | tee /dev/stderr | grep -q 'Total bytes lost: 0'
./dictu tests/runTests.du ci | tee /dev/stderr | grep -q 'Total bytes lost: 0'
- name: Remove build directory
run: |
rm -rf build
Expand All @@ -30,7 +39,7 @@ jobs:
sudo apt-get install -y libcurl4-openssl-dev
cmake -DCMAKE_BUILD_TYPE=Debug -B ./build
cmake --build ./build
./dictu tests/runTests.du | tee /dev/stderr | grep -q 'Total bytes lost: 0'
./dictu tests/runTests.du ci | tee /dev/stderr | grep -q 'Total bytes lost: 0'
test-mac-cmake:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -44,15 +53,15 @@ jobs:
run: |
cmake -DCMAKE_BUILD_TYPE=Debug -DDISABLE_HTTP=1 -B ./build
cmake --build ./build
./dictu tests/runTests.du | tee /dev/stderr | grep -q 'Total bytes lost: 0'
./dictu tests/runTests.du ci | tee /dev/stderr | grep -q 'Total bytes lost: 0'
- name: Remove build directory
run: |
rm -rf build
- name: Make dictu and run tests
run: |
cmake -DCMAKE_BUILD_TYPE=Debug -B ./build
cmake --build ./build
./dictu tests/runTests.du | tee /dev/stderr | grep -q 'Total bytes lost: 0'
./dictu tests/runTests.du ci | tee /dev/stderr | grep -q 'Total bytes lost: 0'
test-windows-cmake:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -66,7 +75,7 @@ jobs:
run: |
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -DCICD=1 -DDISABLE_HTTP=1 -DDISABLE_LINENOISE=1 -B build
cmake --build build
Debug\dictu.exe tests/runTests.du
Debug\dictu.exe tests/runTests.du ci
run-examples:
name: Test Examples
runs-on: ubuntu-latest
Expand All @@ -78,4 +87,4 @@ jobs:
sudo apt-get install -y libcurl4-openssl-dev
cmake -DCMAKE_BUILD_TYPE=Debug -B ./build
cmake --build ./build
./dictu examples/runExamples.du | tee /dev/stderr | grep -q 'Total bytes lost: 0'
./dictu examples/runExamples.du ci | tee /dev/stderr | grep -q 'Total bytes lost: 0'
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,32 @@ $ ./build/Dictu

Refer to [Dictu Docker](https://github.com/dictu-lang/Dictu/blob/develop/Docker/README.md)

### FreeBSD Installation

For a full installation, make sure `curl` and `linenoise` are installed. They can be installed from the commands below:

```bash
$ pkg install -y curl linenoise-ng
```

The following variables need to be set/available to run `cmake` successfully.

For Bourne compatible shells...

```bash
export CPATH=/usr/local/include
export LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/lib
```

```bash
$ git clone -b master https://github.com/dictu-lang/Dictu.git
$ cd Dictu
$ cmake -DCMAKE_BUILD_TYPE=Release -B ./build
$ cmake --build ./build
$ ./dictu
```

## Extensions

Dictu has a Visual Studio Code extension [here](https://marketplace.visualstudio.com/items?itemName=Dictu.dictuvsc) with the implementation located
Expand Down
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: >-
color_scheme: "dictu" # Custom theme
logo: "/assets/images/dictu-logo/dictu-wordmark.svg"

version: "0.25.0"
version: "0.26.0"
github_username: dictu-lang
search_enabled: true

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/built-ins.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The path name of the compilation unit.

Global functions which are built into Dictu.

### print(...values...)
### print(...values)

Prints a given list of values to stdout.

Expand All @@ -35,7 +35,7 @@ print("test"); // "test"
print(10, "test", nil, true); // 10, "test", nil, true
```

### printError(...values...)
### printError(...values)

Prints a given list of values to stderr.

Expand Down
10 changes: 10 additions & 0 deletions docs/docs/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,16 @@ class Test {}
print(Test()._class); // <Cls Test>
```
### _name
`_name` is a special attribute that is added to classes that returns a string representation of the class name.
```cs
class Test {}

print(Test.name); // Test
```
## Class variables
A class variable is a variable that is defined on the class and not the instance. This means that all instances of the class will have access
Expand Down
11 changes: 11 additions & 0 deletions docs/docs/collections/sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ print(mySet.contains("Dictu!")); // true
print(mySet.contains("Other!")); // false
```

### set.containsAll(value)

To check if a set contains all elements in a given list use `.containsAll()`

```cs
var mySet = set("one",1,2,3);;
print(mySet.containsAll(["one",1])); // true
print(mySet.containsAll([1,2,3])); // true
print(mySet.containsAll(["one",1,2,3,"x"])); // false
```

### set.remove(value)

To remove a value from a set use `.remove()`.
Expand Down
17 changes: 17 additions & 0 deletions docs/docs/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,21 @@ class BadClass {
def badFunction(a=5, ...x) {
// ...
}
```

### Argument Unpacking

Sometimes you may have a list of values and you wish to pass them all to a function. Rather than having
to loop over a list within the function and pull out singular values, you can unpack this list at the call site.

Note: This will work on built-ins, class constructors and methods along with functions.

```
const myList = [1, 2, 3];
def printMyList(a, b, c) {
print(a, b, c);
}
printMyList(...myList); // 1 2 3
```
10 changes: 10 additions & 0 deletions docs/docs/standard-lib/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ Env.set("key", nil); // Remove env var
Env.set("key", 10); // set() arguments must be a string or nil.
```

### Env.clearAll()

Clears all set environment variables.

Note: This is not available on Windows systems.

```cs
Env.clearAll();
```

### Env.readFile(string: path -> optional)

To read environment variables from a file this helper method is provided.
Expand Down
62 changes: 52 additions & 10 deletions docs/docs/standard-lib/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ HTTP.get("https://httpbin.org/get", ["Content-Type: application/json"], 1);

### HTTP.post(string, dictionary: postArgs -> optional, list: headers -> optional, number: timeout -> optional)

Sends a HTTP POST request to a given URL.Timeout is given in seconds.
Sends a HTTP POST request to a given URL. Timeout is given in seconds.
Returns a Result and unwraps to a Response upon success.

```cs
Expand All @@ -49,27 +49,69 @@ HTTP.post("https://httpbin.org/post", {"test": 10}, ["Content-Type: application/
HTTP.post("https://httpbin.org/post", {"test": 10}, ["Content-Type: application/json"], 1);
```

### HTTP.newClient(dict)

Creates a new HTTP client with a given set of options.
Returns a Result and neecds to be unwraped upon success.

```cs
const opts = {
"timeout": 20,
"headers": [
"Content-Type: application/json",
"Accept: application/json",
"User-Agent: Dictu"
],
"insecure": false,
"keyFile": "",
"certFile": "",
"keyPasswd": ""
};
var httpClient = HTTP.newClient(opts);
```

### httpClient.get(string)

Sends a HTTP GET request to a given URL.
Returns a Result and unwraps to a Response upon success.

```cs
httpClient.get("https://httpbin.org/get");

{"content": "...", "headers": ["...", "..."], "statusCode": 200}
```

### HTTP.post(string, dictionary: postArgs)

Sends a HTTP POST request to a given URL.
Returns a Result and unwraps to a Response upon success.

```cs
httpClient.post("https://httpbin.org/post");
httpClient.post("https://httpbin.org/post", {"test": 10});
```

### Response

Both HTTP.get() and HTTP.post() return a Result that unwraps a Response object on success, or nil on error.
Both HTTP.get(), HTTP.post(), httpClient.get(), and httpClient.post() return a Result that unwraps a Response object on success, or nil on error.
The Response object returned has 3 public properties, "content", "headers" and "statusCode". "content" is the actual content returned from the
HTTP request as a string, "headers" is a list of all the response headers and "statusCode" is a number denoting the status code from
the response

#### Quick Reference Table
##### Properties

| Property | Description |
|------------|--------------------------------------------------------|
| content | Raw string content returned from the HTTP request |
| headers | A list of headers returned from the HTTP request |
| statusCode | The status code returned from the HTTP request |
| Property | Description |
| ---------- | ------------------------------------------------- |
| content | Raw string content returned from the HTTP request |
| headers | A list of headers returned from the HTTP request |
| statusCode | The status code returned from the HTTP request |

##### Methods

| Method | Description |
|------------|--------------------------------------------------------|
| json | Convert the content property to JSON |
| Method | Description |
| ------ | ------------------------------------ |
| json | Convert the content property to JSON |

Example response from [httpbin.org](https://httpbin.org)

Expand Down
53 changes: 53 additions & 0 deletions docs/docs/standard-lib/object.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
layout: default
title: Object
nav_order: 17
parent: Standard Library
---

# Object
{: .no_toc }

## Table of contents
{: .no_toc .text-delta }

1. TOC
{:toc}

---

## Object

To make use of the Object module an import is required.

```cs
import Object;
```

### Object.getClassRef(string)

This method will attempt to get a class reference from the class name provided as a string.

Returns a Result and unwraps to an Object upon success.

**NOTE:** This currently only works if the class is defined in the global scope

```cs
class Test {}

Object.getClassRef("Test").unwrap(); // <Cls Test>
```

### Object.createFrom(string)

This method will attempt to create a new object from the class name provided as a string.

Returns a Result and unwraps to an Object upon success.

**NOTE:** This currently only works if the class is defined in the global scope

```cs
class Test {}

Object.createFrom("Test").unwrap(); // <Test instance>
```
25 changes: 25 additions & 0 deletions docs/docs/standard-lib/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,28 @@ Note: This is not available on Windows systems.
```cs
System.chown("/path/to/file", 0, 0);
```

### System.uname()

Returns the name and version of the system along with operating system and hardware information.

Note: This is not available on Windows systems.

```cs
System.uname();
```

### System.mkdirTemp(string: directory_template -> optional)

Makes a temporary directory. If an empty string is given, the temporary directory's name will be a random string created in the current working directory. If a string is passed in, the temporary directory will be created with that name in the current working directory.

The directory template passed in **must** end with "XXXXXX".

Returns a Result type and on success will unwrap to a the created directory name.

Note: This is not available on Windows systems.

```cs
System.mkdirTemp().unwrap(); // "VOO16s"
System.mkdirTemp("test_XXXXXX").unwrap(); // "test_0bL2qS"
```
Loading

0 comments on commit ef66697

Please sign in to comment.