dlib — Documentation — Creating scripts


Index:

  1. What is a script?
  2. Script syntax
  3. Running a script

Here, you'll learn how to create a dlib script.

1. What is a script?

A dlib script is a file with .dls extension that contains the instructions to download and install a program.

Here's an example of a dlib script:

- msg "Hello, world!"

You can save this script like script.dls.

This script simply prints "Hello, world!" when executed.

You can run this script by running dlib script.dls.

2. Script syntax

dlib scripts use a simple syntax to define their instructions. Each line represents a command that dlib will execute.

All the instructions are prefixed with a dash (-) and followed by the command and its arguments.

The arguments are separated by commas, unlike index files on repositories.

3. Running a script

To run a dlib script, you can use the dlib command followed by the path to the script file.

You can also use the run argument to run scripts on the internet.

4. Full reference

Here you'll learn all the dlib commands and their usage.

Index:

  1. msg
  2. log, error, warning, info, success
  3. download
  4. mkdir, delete, move, copy, write, append
  5. Variables

msg

The msg command prints a message to the user.

Usage:

- msg "Your message here"

Example:

- msg "Hello, world!"

This command will print "Hello, world!" to the user.

log, error, warning, info, success

These commands print messages to the user with different levels of severity.

Usage:

- log "Your log message here"
- error "Your error message here"
- warning "Your warning message here"
- info "Your info message here"
- success "Your success message here"

Example:

- log "This is a log message"
- error "This is an error message"
- warning "This is a warning message"
- info "This is an info message"
- success "This is a success message"

This will print the corresponding messages to the user with the appropriate formatting.

download

The download command downloads a file from a URL and saves it to a specified location.

Usage:

- download "https://example.com/file.zip", "path/to/save/file.zip"

Example:

- download "https://example.com/file.zip", "file.zip"

This command will download the file from the specified URL and save it as file.zip in the current directory.

mkdir, delete, move, copy, write, append

These commands allow you to perform various file operations.

Usage:

- mkdir "path/to/new/directory"
- delete "path/to/file"
- move "path/to/source", "path/to/destination"
- copy "path/to/source", "path/to/destination"
- write "path/to/file", "content"
- append "path/to/file", "content"

Example:

- mkdir "new_folder"
- write "new_folder/hello.txt", "Hello, world!"
- append "new_folder/hello.txt", "\nWelcome to dlib scripting!"

This will create a new folder called new_folder, create a file called hello.txt inside that folder with the content "Hello, world!", and then append "Welcome to dlib scripting!" to that file.

Variables

You can use variables in your scripts to store and manipulate data.

Usage:

- set variable_name, "value"

Example:

- set name, "Alice"
- msg "Hello, $name!"

This will print "Hello, Alice!" to the user.