diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-05-19 14:47:03 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-05-19 14:47:03 -0400 |
| commit | 3d313c5956510a807c2ce7d1ffd9c3bfbb708444 (patch) | |
| tree | 3328712914f1549b9fee01b363cd9a8ad628384c | |
| parent | 890c7cc389c0507ecb996f7f93ba484eda512782 (diff) | |
Add --prefix flag
| -rw-r--r-- | CHANGES.md | 1 | ||||
| -rw-r--r-- | docs/tomo.1.md | 3 | ||||
| -rw-r--r-- | man/man1/tomo.1 | 3 | ||||
| -rw-r--r-- | src/tomo.c | 7 |
4 files changed, 14 insertions, 0 deletions
@@ -6,6 +6,7 @@ configuration for module aliases. - Programs can use `--version` as a CLI flag to print a Tomo program's version number and exit. +- Added `tomo --prefix` to print the Tomo install prefix. - Added Path.sibling() ## v0.2 diff --git a/docs/tomo.1.md b/docs/tomo.1.md index 7ccf0397..4207de6a 100644 --- a/docs/tomo.1.md +++ b/docs/tomo.1.md @@ -62,5 +62,8 @@ C code, which is then compiled using a C compiler of your choice. `--version` : Print the compiler version and exit. +`--prefix` +: Print the Tomo installation prefix and exit. + `-r`, `--run` : Run an installed tomo program from `~/.local/share/tomo_vX.Y/installed`. diff --git a/man/man1/tomo.1 b/man/man1/tomo.1 index 32b366a6..4b4f16bd 100644 --- a/man/man1/tomo.1 +++ b/man/man1/tomo.1 @@ -60,6 +60,9 @@ Print extra verbose output. \f[B]\-\-version\f[R] Print the compiler version and exit. .TP +\f[B]\-\-prefix\f[R] +Print the Tomo installation prefix and exit. +.TP \f[B]\-r\f[R], \f[B]\-\-run\f[R] Run an installed tomo program from \f[B]\[ti]/.local/share/tomo_vX.Y/installed\f[R]. @@ -64,6 +64,7 @@ static OptionalList_t files = NONE_LIST, static OptionalBool_t verbose = false, quiet = false, show_parse_tree = false, + show_prefix = false, stop_at_transpile = false, stop_at_obj_compilation = false, compile_exe = false, @@ -189,6 +190,7 @@ int main(int argc, char *argv[]) {"v", false, &Bool$info, &verbose}, {"parse", false, &Bool$info, &show_parse_tree}, {"p", false, &Bool$info, &show_parse_tree}, + {"prefix", false, &Bool$info, &show_prefix}, {"quiet", false, &Bool$info, &quiet}, {"q", false, &Bool$info, &quiet}, {"transpile", false, &Bool$info, &stop_at_transpile}, @@ -213,6 +215,11 @@ int main(int argc, char *argv[]) {"m", false, &Bool$info, &source_mapping}, ); + if (show_prefix) { + print(TOMO_PREFIX); + return 0; + } + bool is_gcc = (system(String(cc, " -v 2>&1 | grep -q 'gcc version'")) == 0); if (is_gcc) { cflags = Texts(cflags, Text(" -fsanitize=signed-integer-overflow -fno-sanitize-recover" |
