Git Product home page Git Product logo

aish's Introduction

aish - aiscript shell

  • This software is unofficial and not related to aiscript-dev.
$ aish -h

Usage:   aish
Version: 0.1.0

Options:

  -h, --help     - Show this help.
  -V, --version  - Show the version number for this program.

Commands:

  run   <path>  - execute script file.
  repl          - run repl.

$ aish repl
> Core:ai
"kawaii"

Installation

deno install -A -n aish --import-map https://raw.githubusercontent.com/ikasoba/aish/main/import_map.json https://raw.githubusercontent.com/ikasoba/aish/main/cli.ts

About

aish automatically turns undeclared variables into helpers for executing commands.

You can also declare variables in the same way as in regular aiscript.

> echo("Hello, world!").exec()
Hello, world!
null
> echo(1).pipe(xargs("expr", 1, "+")).exec()
2
null

API Reference

Command#exec(): null

The exec method of the command outputs standard output and standard error as is and returns null.

Command#read(): str | error

Command's read method is used to retrieve stdout and stderr.

Only in case of an error, the standard error is returned.

FakeModule:import(path: str): obj

  • This feature is experimental.

This feature can be used to load external aiscript code.

As a precaution, some features such as namespaces will not be available.

This is because aish internally executes the contents of the code as a function.

Module loading is performed according to the following rules

  • If the path starts with /, then

    Load from <home>/.aish/.

  • Otherwise.

    Import from the same hierarchy as the running script file.

Also, JavaScript can be loaded.

example

// ./hoge.is

@add(x, y) {
  return x + y
}

return {
  add: add
}
// ./hoge.js

import { values, utils } from "@syuilo/aiscript/";

export default () => (
  values.OBJ(new Map([
    ["add", values.FN_NATIVE(([x, y]) => {
      utils.assertNumber(x);
      utils.assertNumber(y);

      return values.NUM(x.value + y.value);
    })]
  ]))
)
let Hoge = FakeModule:import("./hoge.is")

<: Hoge.add(1, 2)

// or

let Hoge = FakeModule:import("./hoge.js")

<: Hoge.add(1, 2)

.aishrc

aish has a .bashrc like feature called .aishrc.

It must be placed as valid AiScript code directly under the user's home directory (such as /home/user/.aishrc).

aish's People

Contributors

ikasoba avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.