aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AGENTS/ARCH.md3
-rw-r--r--doc/cpsc.md7
-rw-r--r--tools/driver/main.cc11
3 files changed, 20 insertions, 1 deletions
diff --git a/AGENTS/ARCH.md b/AGENTS/ARCH.md
index 8245027..247bce1 100644
--- a/AGENTS/ARCH.md
+++ b/AGENTS/ARCH.md
@@ -59,6 +59,9 @@ Driver behavior (`tools/driver/main.cc`):
- One source file, with optional `-o path` and `-r`; options may precede or follow the source.
No stdin source input. Missing input, including no arguments, prints
`cpsc: fatal error: no input files` and `compilation terminated.`, then returns 1.
+- `-h` anywhere in the arguments prints one documentation pointer to stdout and
+ returns 0 without compiling: `man 1 cpsc` on Unix/macOS, or
+ Start Menu > cpsc > cpsc Help on Windows (selected by `_WIN32`).
- IR is written only after successful parsing, code generation and module
verification. Diagnostics stay on stderr; failures do not overwrite existing IR.
- Lexer, Parser and CodeGen track error flags (`hadError()`); any error, including
diff --git a/doc/cpsc.md b/doc/cpsc.md
index 98340aa..fa4ae2b 100644
--- a/doc/cpsc.md
+++ b/doc/cpsc.md
@@ -8,6 +8,8 @@ cpsc - compile and run CIE pseudocode
**cpsc** [**-r**] [**-o** *output*] *source*
+**cpsc** **-h**
+
# DESCRIPTION
Compile one pseudocode source file to LLVM IR. Options may appear before or after the source path. Source input from stdin is not supported.
@@ -16,6 +18,9 @@ Without **-o** or **-r**, replace the source filename's extension with `.ir` and
# OPTIONS
+**-h**
+: Print only the documentation entry point: `man 1 cpsc` on Unix/macOS, or Start Menu > cpsc > cpsc Help on Windows. Return successfully without compiling, even when other arguments are present.
+
**-o** *output*
: Save IR to the specified path. May be specified only once. With **-r**, keep this file even if execution fails.
@@ -64,7 +69,7 @@ cpsc test.cps -r -o result.ir
# EXIT STATUS
**0**
-: Compilation succeeded.
+: Compilation succeeded, or **-h** printed the documentation entry point.
**1**
: An argument, file, compilation or execution-engine error occurred, including missing input, when PATH mode cannot find `lli` or NONE mode receives **-r**.
diff --git a/tools/driver/main.cc b/tools/driver/main.cc
index d670ac0..a4616bd 100644
--- a/tools/driver/main.cc
+++ b/tools/driver/main.cc
@@ -23,6 +23,17 @@ int compilationTerminated() {
} // namespace
int main(int argc, char **argv) {
+ for (int I = 1; I < argc; ++I) {
+ if (std::string(argv[I]) == "-h") {
+#ifdef _WIN32
+ llvm::outs() << "See Start Menu > cpsc > cpsc Help for HTML help.\n";
+#else
+ llvm::outs() << "See man 1 cpsc for help.\n";
+#endif
+ return 0;
+ }
+ }
+
std::string InputPath;
std::string OutputPath;
bool Run = false;