Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
79a3028
CLI version using inline
softmattertheory Feb 11, 2026
bd8877d
Correctly free input
softmattertheory Feb 11, 2026
6e68eca
-version CLI option
softmattertheory Feb 11, 2026
610e62d
Restructure option processing
softmattertheory Feb 12, 2026
ea2cf0f
Option handling
softmattertheory Feb 12, 2026
7e11202
Use inexact match
softmattertheory Feb 12, 2026
e8dc6f3
Command line eval option
softmattertheory Feb 12, 2026
6fa618a
Remove help files as they're in the main morpho repo
softmattertheory Feb 12, 2026
7faf223
Check option
softmattertheory Feb 12, 2026
7a99b88
Interactive flag
softmattertheory Feb 12, 2026
5cde689
Code organization
softmattertheory Feb 12, 2026
efd7776
Interactive mode
softmattertheory Feb 12, 2026
ddf13db
--list option
softmattertheory Feb 12, 2026
3319d27
Syntax highlight comments
softmattertheory Feb 12, 2026
bb05fc9
Help
softmattertheory Feb 12, 2026
1bfa4e1
Correct behavior in pipes
softmattertheory Feb 13, 2026
d1b92f6
Fix disassemble only
softmattertheory Feb 13, 2026
db6ce34
Improve colors
softmattertheory Feb 13, 2026
3197388
Check terminal width correctly
softmattertheory Feb 13, 2026
e33194f
Color operators
softmattertheory Feb 13, 2026
8501c88
--no-color option
softmattertheory Feb 13, 2026
6cf06b3
CLI output ensure terminal support has been checked
softmattertheory Feb 13, 2026
692c2fa
Correct passing of args to morpho runtime
softmattertheory Feb 13, 2026
573762c
Remove profiler qualifiers
softmattertheory Feb 14, 2026
5d80eb7
Clean up terminal code
softmattertheory Feb 14, 2026
344c8c1
Remove unused variables
softmattertheory Feb 14, 2026
e0d470f
Updated inline.c
softmattertheory Feb 14, 2026
f15cdcf
String interpolation fixed
softmattertheory Feb 14, 2026
30a666e
Update inline.h
softmattertheory Feb 14, 2026
f4d4e7e
Update inline to latest version
softmattertheory Feb 15, 2026
44eb6e0
Minimal use of new help system
softmattertheory Feb 17, 2026
9591b61
Now retrieve topic
softmattertheory Feb 17, 2026
52a3864
First go at new help display
softmattertheory Feb 17, 2026
2c51bc7
Strip leading spaces
softmattertheory Feb 17, 2026
6c27c6a
Spacing between code lines
softmattertheory Feb 17, 2026
548d262
Clean up cli_matchdelimiter
softmattertheory Feb 17, 2026
17c94d2
Clean cli_displayline
softmattertheory Feb 17, 2026
2ba856e
Clean cli_displaytopic
softmattertheory Feb 17, 2026
c00b348
Simplify code display
softmattertheory Feb 17, 2026
b35b21e
Remove stray newline after header
softmattertheory Feb 17, 2026
f5e87ea
Separating out cli_displayblocklines
softmattertheory Feb 17, 2026
2e4b45a
Move help functions into hlp.c and hlp.h
softmattertheory Feb 17, 2026
293d77b
Blank query and topic list
softmattertheory Feb 18, 2026
ca3159f
Debugger commands
softmattertheory Feb 18, 2026
90ccd7b
Highlight at in red
softmattertheory Feb 18, 2026
7dce523
Fix styled output
softmattertheory Feb 18, 2026
44b0d44
Update hlp.c
softmattertheory Feb 18, 2026
9e88017
Show subtopics
softmattertheory Feb 18, 2026
60fd856
Fix error in unistring codepath
softmattertheory Feb 19, 2026
1e83d29
Fix help query
softmattertheory Feb 24, 2026
28e2ff2
Detect MORPHO_INCLUDE_HELP for includes
softmattertheory Feb 26, 2026
6370fc3
Update .gitignore
softmattertheory May 20, 2026
d58da08
CLI exit codes
softmattertheory Jul 27, 2026
aa23a2e
Update README.md
softmattertheory Jul 28, 2026
6d3cdf8
Perform help queries from the command line
softmattertheory Jul 28, 2026
c681264
Fix option parsing bugs
softmattertheory Jul 28, 2026
8a202d2
Update README.md
softmattertheory Jul 28, 2026
763a533
Enables --eval code to run as a preamble.
softmattertheory Jul 28, 2026
2e38e46
Consolidate some redundant code
softmattertheory Jul 28, 2026
91096ad
Add CI
softmattertheory Jul 28, 2026
b6305db
Allow a raw query "help" query to generate a topic list
softmattertheory Jul 28, 2026
736dd17
Update README.md
softmattertheory Jul 28, 2026
cc67fdc
Route write through inline_write to avoid no check warnings
softmattertheory Jul 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/scripts/smoke-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
# Smoke tests for morpho6 CLI (install / PR gate).
set -euo pipefail

MORPHO6="${MORPHO6:-morpho6}"

expect_ok() {
local desc="$1"
shift
echo "==> $desc"
"$@"
}

expect_fail() {
local desc="$1"
shift
echo "==> $desc (expect failure)"
if "$@"; then
echo "expected failure, but succeeded: $*" >&2
exit 1
fi
}

expect_contains() {
local desc="$1"
local needle="$2"
shift 2
echo "==> $desc"
local out
out="$("$@" 2>&1)" || true
if ! grep -Fq -- "$needle" <<<"$out"; then
echo "expected output to contain: $needle" >&2
echo "got:" >&2
echo "$out" >&2
exit 1
fi
}

# Basic eval / version / help
expect_ok "version" "$MORPHO6" --version
expect_ok "eval" "$MORPHO6" -e 'print(1)'
expect_ok "multiple -e preamble" "$MORPHO6" -e 'var x = 1' -e 'print(x)'

# Help queries
expect_contains "CLI usage" "Usage: morpho6" "$MORPHO6" --help
expect_contains "help index topic" "Topics:" "$MORPHO6" --no-color --help help
expect_contains "help Matrix" "Matrix" "$MORPHO6" --no-color --help Matrix
expect_fail "unknown help topic" "$MORPHO6" --no-color --help NotARealTopicXYZ123

# Option parsing
expect_ok "workers" "$MORPHO6" --workers 2 -e 'print(1)'
expect_ok "disassemble only" "$MORPHO6" -D -e 'print(1)'
expect_contains "disassemble with source" ">>> 1 :" "$MORPHO6" --no-color -dl -e 'print(1)'

# -D must not execute (disassembly may still mention constants)
out="$("$MORPHO6" -D -e 'print("EXECUTED")' 2>&1)" || true
if grep -Eq '^EXECUTED$' <<<"$out"; then
echo "-D should not execute the program" >&2
echo "$out" >&2
exit 1
fi

# Failure exit codes
expect_fail "missing list file" "$MORPHO6" -l /no/such/file.morpho
expect_fail "bad eval" "$MORPHO6" -e 'var x ='
expect_fail "unknown option" "$MORPHO6" --not-a-real-option

# File + preamble
tmp="$(mktemp /tmp/morpho-smoke.XXXXXX.morpho)"
trap 'rm -f "$tmp"' EXIT
printf 'print(x)\n' >"$tmp"
expect_ok "eval preamble + file" "$MORPHO6" -e 'var x = 7' "$tmp"

# Piped stdin + preamble
expect_ok "eval preamble + stdin" bash -c "printf 'print(x)\n' | $MORPHO6 -e 'var x = 3'"

# NO_COLOR / --no-color should not emit CSI sequences for help
out="$(NO_COLOR=1 "$MORPHO6" --help Matrix 2>&1)" || true
if grep -Eq $'\x1B\[' <<<"$out"; then
echo "NO_COLOR=1 still produced ANSI escapes" >&2
exit 1
fi

echo "All smoke tests passed."
38 changes: 38 additions & 0 deletions .github/workflows/basic-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Basic install

on:
push:
branches: [ "main", "inline" ]
pull_request:
branches: [ "main", "inline" ]

jobs:
basic-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Install Morpho dependencies
run: |
sudo apt update
sudo apt install -y libsuitesparse-dev liblapacke-dev libunistring-dev

- name: Build and install Morpho
run: |
git clone --depth 1 --branch dev https://github.com/Morpho-lang/morpho.git
cd morpho
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
sudo cmake --install build --config Release
sudo ldconfig

- name: Build and install morpho-cli
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
sudo cmake --install build --config Release

- name: Smoke test morpho6
run: |
chmod +x .github/scripts/smoke-test.sh
.github/scripts/smoke-test.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ build-xcode/*
.vscode/*
.vscode/settings.json
/.vscode
REVIEW.md
/dist
52 changes: 36 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

# Morpho-cli

A terminal app for the [morpho language](https://github.com/Morpho-lang/morpho). Improved unicode support requires an external library e.g. [libgrapheme](https://libs.suckless.org/libgrapheme/) or [libunistring](https://www.gnu.org/software/libunistring/).
A terminal app for the [morpho language](https://github.com/Morpho-lang/morpho) using the [inline line editor](https://github.com/Morpho-lang/inline). Improved unicode support requires an external library e.g. [libgrapheme](https://libs.suckless.org/libgrapheme/) or [libunistring](https://www.gnu.org/software/libunistring/).

Like morpho itself, Morpho-cli is released under an MIT license (see the LICENSE file for details). See the [main morpho repository](https://github.com/Morpho-lang/morpho) for information about contributing etc. Please report any issues or feature requests about the morpho-cli terminal app specifically here: suggestions for improvement are very welcome.

## Installation

For this release, morpho can be installed on all supported platforms using the homebrew package manager. Alternatively, the program can be installed from source as described below.

### Install with homebrew

The simplest way to install morpho-cli is through the [homebrew package manager](https://brew.sh). To do so:
The simplest way to install the morpho terminal app is to use the [homebrew package manager](https://brew.sh). To do so:

1. If not already installed, install homebrew on your machine as described on the [homebrew website](https://brew.sh)

Expand All @@ -26,7 +22,36 @@ brew install morpho morpho-cli morpho-morphoview morpho-morphopm

If you need to uninstall morpho, simply open a terminal and type `brew uninstall morpho-cli morpho-morphoview morpho`. It's very important to uninstall the homebrew morpho in this way before attempting to install from source as below.

### Install from source
## Running

To run type,

morpho6

into a terminal. The terminal app takes a number of optional arguments:

| Option | Description |
|--------|-------------|
| `-h`, `--help [query]` | Show CLI help, or look up a language help topic |
| `-v`, `--version` | Show version information |
| `-c`, `--check` | Check syntax without executing |
| `-e`, `--eval <code>` | Execute a code string (before file/REPL if combined) |
| `-i`, `--interactive` | Enter REPL after running a file |
| `-l`, `--list <file>` | List a file with syntax highlighting |
| `-d`, `--disassemble` | Show disassembly |
| `-D` | Disassemble only (no execution) |
| `-dl` | Disassemble with source listing |
| `-debug`, `--debug` | Enable debugger |
| `-O`, `--optimize` | Enable optimizations |
| `-profile`, `--profile` | Enable profiling |
| `--no-color` | Disable syntax highlighting |
| `-w`, `--workers <n>` | Set number of worker threads |

If no file is specified, morpho enters interactive mode. If stdin is piped or redirected, morpho reads and executes from stdin. Any options after the file name are passed to the morpho program and are available from the `System` class:

var args = System.arguments()

## Manual install from source

To install, clone this repository:

Expand All @@ -35,13 +60,8 @@ To install, clone this repository:
and then,

cd morpho-cli
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make install
cmake -S . -B build
cmake --build build --config Release
sudo cmake --install build --config Release

You may need to use sudo make install.

To run,

morpho6
This manual build installs into '/usr/local/bin' by default.
20 changes: 0 additions & 20 deletions help/Makefile

This file was deleted.

34 changes: 0 additions & 34 deletions help/array.md

This file was deleted.

Loading