Skip to content

Commit 3489d0c

Browse files
Rafael-SOWNetclaude
andcommitted
The Terminal's .deb installs amcli, with a man page and completion
The package's launcher, angourimath-terminal, ran the Terminal without its arguments, so the one-shot commands of #1654 could not be reached from the .deb, and the package had no amcli command at all. The launcher now has a shebang and passes "$@" on, and amcli is a link to it. The package also installs amcli.1 under /usr/share/man/man1 (#1658) and a bash completion script for the commands under /usr/share/bash-completion/completions (#1659). The script packs under umask 022, so that the package's modes do not depend on who packs it: under a stricter umask, dpkg-deb refused the control directory, and the installed files would have been unreadable to other users. Closes #1658, closes #1659, part of #1660. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
1 parent 7219aea commit 3489d0c

4 files changed

Lines changed: 102 additions & 1 deletion

File tree

‎.github/workflows/TerminalNightly.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
- '.github/workflows/TerminalNightly.yml'
1515
- 'Sources/Terminal/AngouriMath.Terminal/publish.sh'
1616
- 'Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh'
17+
- 'Sources/Terminal/AngouriMath.Terminal/amcli.1'
18+
- 'Sources/Terminal/AngouriMath.Terminal/amcli.bash'
1719
workflow_dispatch:
1820
inputs:
1921
version:
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
.TH AMCLI 1 "" "AngouriMath" "User Commands"
2+
.SH NAME
3+
amcli \- the AngouriMath terminal, and commands that answer once
4+
.SH SYNOPSIS
5+
.B amcli
6+
.br
7+
.B amcli
8+
.I command
9+
.RI [ argument ...]
10+
.SH DESCRIPTION
11+
With no arguments,
12+
.B amcli
13+
opens the AngouriMath terminal: an F# prompt with AngouriMath loaded.
14+
.PP
15+
With a command,
16+
.B amcli
17+
answers once and exits, without starting F#, so that it can sit in a pipe or a script.
18+
An argument written as
19+
.BR _ ,
20+
or left out, is read from standard input.
21+
.SH COMMANDS
22+
.TP
23+
.BI eval " expr"
24+
Evaluates
25+
.I expr
26+
to a number, a boolean, or a + bi. A rational is written as a decimal.
27+
.TP
28+
.BI simp " expr"
29+
Simplifies
30+
.IR expr .
31+
.TP
32+
.BI fsimp " expr"
33+
Simplifies
34+
.I expr
35+
quickly: the normalisation, without the search.
36+
.TP
37+
.BI diff " var expr"
38+
Differentiates
39+
.I expr
40+
over
41+
.IR var .
42+
.TP
43+
.BI solve " var statement"
44+
Solves
45+
.I statement
46+
over
47+
.IR var ,
48+
one root per line when there are finitely many.
49+
.TP
50+
.BI sub " var value expr"
51+
Substitutes
52+
.I value
53+
for
54+
.I var
55+
in
56+
.IR expr .
57+
.TP
58+
.BI latex " expr"
59+
Writes
60+
.I expr
61+
as LaTeX.
62+
.TP
63+
.B help
64+
Lists the commands.
65+
.SH EXIT STATUS
66+
0 for an answer; 1 when the input does not parse or cannot be answered; 2 for a command that
67+
does not exist or is missing an argument.
68+
.SH EXAMPLES
69+
.nf
70+
$ amcli simp "sin(x)^2 + cos(x)^2"
71+
1
72+
$ amcli solve x "x^2 \- 1 = 0"
73+
1
74+
\-1
75+
$ echo "1 + x^2" | amcli diff x
76+
2 * x
77+
.fi
78+
.SH SEE ALSO
79+
https://am.angouri.org
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Bash completion for amcli, the AngouriMath terminal: the command after it.
2+
_amcli()
3+
{
4+
local current="${COMP_WORDS[COMP_CWORD]}"
5+
if [ "$COMP_CWORD" -eq 1 ]; then
6+
COMPREPLY=( $(compgen -W "eval simp fsimp diff solve sub latex help" -- "$current") )
7+
fi
8+
}
9+
complete -F _amcli amcli angourimath-terminal

‎Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# The .deb's version is the release's: TerminalNightly.yml passes the packages' version, read
33
# from the release's tag.
44
version="${TERMINAL_VERSION:?set TERMINAL_VERSION to the version to pack, such as 2.6.0}"
5+
# The package's modes come from the umask it is packed under: dpkg-deb refuses a control directory
6+
# other users cannot read, and what it installs has to be readable by them too.
7+
umask 022
58
cd publish-output
69

710
for arch in amd64 arm arm64
@@ -27,8 +30,16 @@ do
2730
mkdir -p ./usr/share/applications/
2831
cp -r ../$dotnet_arch ./usr/local/bin
2932
mv ./usr/local/bin/$dotnet_arch ./usr/local/bin/angourimath-terminal-data
30-
echo 'cd /usr/local/bin/angourimath-terminal-data && ./AngouriMath.Terminal' > ./usr/local/bin/angourimath-terminal
33+
# The arguments go through, so that `amcli simp "..."` answers once, and amcli is the same
34+
# launcher under the name the dotnet tool has.
35+
printf '#!/bin/sh\ncd /usr/local/bin/angourimath-terminal-data && exec ./AngouriMath.Terminal "$@"\n' > ./usr/local/bin/angourimath-terminal
3136
chmod +x ./usr/local/bin/angourimath-terminal
37+
ln -s angourimath-terminal ./usr/local/bin/amcli
38+
39+
mkdir -p ./usr/share/man/man1/
40+
gzip -9 -n -c ../../amcli.1 > ./usr/share/man/man1/amcli.1.gz
41+
mkdir -p ./usr/share/bash-completion/completions/
42+
install -m 0644 ../../amcli.bash ./usr/share/bash-completion/completions/amcli
3243

3344
mkdir DEBIAN && cd DEBIAN
3445
touch control

0 commit comments

Comments
 (0)