diff --git a/.github/workflows/TerminalNightly.yml b/.github/workflows/TerminalNightly.yml index ef5ec31d7..374d826eb 100644 --- a/.github/workflows/TerminalNightly.yml +++ b/.github/workflows/TerminalNightly.yml @@ -14,6 +14,8 @@ on: - '.github/workflows/TerminalNightly.yml' - 'Sources/Terminal/AngouriMath.Terminal/publish.sh' - 'Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh' + - 'Sources/Terminal/AngouriMath.Terminal/amcli.1' + - 'Sources/Terminal/AngouriMath.Terminal/amcli.bash' workflow_dispatch: inputs: version: diff --git a/Sources/Terminal/AngouriMath.Terminal/amcli.1 b/Sources/Terminal/AngouriMath.Terminal/amcli.1 new file mode 100644 index 000000000..80955f7f7 --- /dev/null +++ b/Sources/Terminal/AngouriMath.Terminal/amcli.1 @@ -0,0 +1,85 @@ +.TH AMCLI 1 "" "AngouriMath" "User Commands" +.SH NAME +amcli \- the AngouriMath terminal, and commands that answer once +.SH SYNOPSIS +.B amcli +.br +.B amcli +.I command +.RI [ argument ...] +.SH DESCRIPTION +With no arguments, +.B amcli +opens the AngouriMath terminal: an F# prompt with AngouriMath loaded. +.PP +With a command, +.B amcli +answers once and exits, without starting F#, so that it can sit in a pipe or a script. +An argument written as +.BR _ , +or left out, is read from standard input. +.SH COMMANDS +.TP +.BI eval " expr" +Evaluates +.I expr +to a number, a boolean, or a + bi. A rational is written as a decimal. +.TP +.BI simp " expr" +Simplifies +.IR expr . +.TP +.BI fsimp " expr" +Simplifies +.I expr +quickly: the normalisation, without the search. +.TP +.BI diff " var expr" +Differentiates +.I expr +over +.IR var . +.TP +.BI solve " var statement" +Solves +.I statement +over +.IR var , +one root per line when there are finitely many. +.TP +.BI sub " var value expr" +Substitutes +.I value +for +.I var +in +.IR expr . +.TP +.BI latex " expr" +Writes +.I expr +as LaTeX. +.TP +.BI info " expr" +Describes +.IR expr : +its variables, the derivative and the roots over each, and its stationary points, each classified +by the second derivative test. +.TP +.B help +Lists the commands. +.SH EXIT STATUS +0 for an answer; 1 when the input does not parse or cannot be answered; 2 for a command that +does not exist or is missing an argument. +.SH EXAMPLES +.nf +$ amcli simp "sin(x)^2 + cos(x)^2" +1 +$ amcli solve x "x^2 \- 1 = 0" +1 +\-1 +$ echo "1 + x^2" | amcli diff x +2 * x +.fi +.SH SEE ALSO +https://am.angouri.org diff --git a/Sources/Terminal/AngouriMath.Terminal/amcli.bash b/Sources/Terminal/AngouriMath.Terminal/amcli.bash new file mode 100644 index 000000000..a909bd994 --- /dev/null +++ b/Sources/Terminal/AngouriMath.Terminal/amcli.bash @@ -0,0 +1,9 @@ +# Bash completion for amcli, the AngouriMath terminal: the command after it. +_amcli() +{ + local current="${COMP_WORDS[COMP_CWORD]}" + if [ "$COMP_CWORD" -eq 1 ]; then + COMPREPLY=( $(compgen -W "eval simp fsimp diff solve sub latex info help" -- "$current") ) + fi +} +complete -F _amcli amcli angourimath-terminal diff --git a/Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh b/Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh index e5f09a638..9a0e2723a 100755 --- a/Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh +++ b/Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh @@ -2,6 +2,9 @@ # The .deb's version is the release's: TerminalNightly.yml passes the packages' version, read # from the release's tag. version="${TERMINAL_VERSION:?set TERMINAL_VERSION to the version to pack, such as 2.6.0}" +# The package's modes come from the umask it is packed under: dpkg-deb refuses a control directory +# other users cannot read, and what it installs has to be readable by them too. +umask 022 cd publish-output for arch in amd64 arm arm64 @@ -27,8 +30,16 @@ do mkdir -p ./usr/share/applications/ cp -r ../$dotnet_arch ./usr/local/bin mv ./usr/local/bin/$dotnet_arch ./usr/local/bin/angourimath-terminal-data - echo 'cd /usr/local/bin/angourimath-terminal-data && ./AngouriMath.Terminal' > ./usr/local/bin/angourimath-terminal + # The arguments go through, so that `amcli simp "..."` answers once, and amcli is the same + # launcher under the name the dotnet tool has. + printf '#!/bin/sh\ncd /usr/local/bin/angourimath-terminal-data && exec ./AngouriMath.Terminal "$@"\n' > ./usr/local/bin/angourimath-terminal chmod +x ./usr/local/bin/angourimath-terminal + ln -s angourimath-terminal ./usr/local/bin/amcli + + mkdir -p ./usr/share/man/man1/ + gzip -9 -n -c ../../amcli.1 > ./usr/share/man/man1/amcli.1.gz + mkdir -p ./usr/share/bash-completion/completions/ + install -m 0644 ../../amcli.bash ./usr/share/bash-completion/completions/amcli mkdir DEBIAN && cd DEBIAN touch control