assistscript
v1.4.2
Published
AssistScript is a custom command based language
Downloads
18
Readme
AssistScript
Table of Contents
Introduction📜
AssistScript is a simple scripting(?) language that I made for fun. Not very useful, but it's fun to play around with. Initially started as a joke, and as time passed it became a fun project to work on.
The language is a straightforward, all you have to do is to specify a command and its arguments. The basic syntax is:
<command> <arg1> <arg2> ... <argN>
eg:
add 10 20 40
Outputs 70
✨ Want to try out the language? Check out the AssistScript Runner
Installation📲
You can install AssistScript using npm.
npm install -g assistscript
This installs the AssistScript CLI globally on your system.
If you don't want AssistScript to be installed globally,
you can omit the -g
flag or use npx
to run AssistScript without installing it.
Demos▶️
Want to see what the language can do? Check out the demos🧪 directory for some examples.
These demos are simple programs that demonstrate the language's features. You can run them using the CLI.
Sample Program - Bubble Sort🔢
Here is bubble sort in AssistScript:
(array arr 4 5 2 4 5 6 7 1)
(for (set i 0) (lt (get i) (len arr)) (incr i) (
(for (set j 0) (lt (get j) (sub (len arr) (get i) 1)) (incr j) (
(if (gt
(index arr (get j))
(index arr (add (get j) 1))
) (
(set temp (index arr (get j)))
(set-arr arr (get j) (index arr (add (get j) 1)))
(set-arr arr (add (get j) 1) (get temp))
))
))
))
(for (set i 0) (lt (get i) (len arr)) (incr i) (
(print (index arr (get i)))
))
Output:
1
2
4
4
5
5
6
7
Visit the online AssistScript runner to run assistscript programs online.
Usage✍
AssistScript can be used in multiple ways. You can use it as a standalone program in the terminal using the AssistScript CLI, or you can use it inside your JavaScript code.
Using terminal💻
You can run AssistScript using the terminal. The AssistScript package comes with a command-line interface to run AssistScript files. It also has a REPL mode to run commands interactively.
# Without installing the package
npx assistscript
OR
# Once the package is installed
aslangc
The above commands, once executed, will show the help menu for the CLI.
📝 You can interchangeably use
aslangc
andassistscript
in the terminal.
REPL mode⌨️
You can run the REPL mode by using the -r
or --repl
flag.
aslangc -r
File Mode📂
You can run AssistScript(.asrc) files using the CLI by providing the path to the file.
aslangc <path-to-file>
Using the API💻
You can also use AssistScript in your JavaScript code, for this AssistScript exposes a simple API.
The AssistScript
class is the main class that you can use run AssistScript code.
import {AssistScript} from 'assistscript';
const as = new AssistScript();
// Prints 70
console.log(as.run('add 10 20 30'));
// Prints 50 <- (100 - 20 - (10 + 20))
console.log(as.run('sub 100 20 (add 10 20)'));
Want to learn more?🏫
Check out the documentation📃 for more information on the language and its features.
- To learn more about the implementations, check out the implementation.
- For additional information, check out the additional info.
- To get started with creating custom commands, check out the custom commands.
- To create custom context, check out the custom context.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Made with 💙 by fbn776