mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	A few minor improvements.
- Add long-form CLI options - Update changelog. - Use snprintf instead of sprintf for linters.
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -134,6 +134,9 @@ Module.symvers | |||||||
| Mkfile.old | Mkfile.old | ||||||
| dkms.conf | dkms.conf | ||||||
|  |  | ||||||
|  | # Coverage files | ||||||
|  | *.cov | ||||||
|  |  | ||||||
| # End of https://www.gitignore.io/api/c | # End of https://www.gitignore.io/api/c | ||||||
|  |  | ||||||
| # Created by https://www.gitignore.io/api/cmake | # Created by https://www.gitignore.io/api/cmake | ||||||
|   | |||||||
| @@ -1,6 +1,10 @@ | |||||||
| # Changelog | # Changelog | ||||||
| All notable changes to this project will be documented in this file. | All notable changes to this project will be documented in this file. | ||||||
|  |  | ||||||
|  | ## Unreleased - ??? | ||||||
|  | - Add long form command line options for readable CLI usage | ||||||
|  | - Fix bug with `net/accept-loop` that would sometimes miss connections. | ||||||
|  |  | ||||||
| ## 1.34.0 - 2024-03-22 | ## 1.34.0 - 2024-03-22 | ||||||
| - Add a new (split) PEG special by @ianthehenry | - Add a new (split) PEG special by @ianthehenry | ||||||
| - Add buffer/push-* sized int and float by @pnelson | - Add buffer/push-* sized int and float by @pnelson | ||||||
|   | |||||||
| @@ -4020,6 +4020,28 @@ | |||||||
|     (def x (in args (+ i 1))) |     (def x (in args (+ i 1))) | ||||||
|     (or (scan-number x) (keyword x))) |     (or (scan-number x) (keyword x))) | ||||||
|  |  | ||||||
|  |   (def- long-to-short | ||||||
|  |     "map long options to short options" | ||||||
|  |     {"-help" "h" | ||||||
|  |      "-version" "v" | ||||||
|  |      "-stdin" "s" | ||||||
|  |      "-eval" "e" | ||||||
|  |      "-expression" "E" | ||||||
|  |      "-debug" "d" | ||||||
|  |      "-repl" "r" | ||||||
|  |      "-noprofile" "R" | ||||||
|  |      "-persistent" "p" | ||||||
|  |      "-quiet" "q" | ||||||
|  |      "-flycheck" "k" | ||||||
|  |      "-syspath" "m" | ||||||
|  |      "-compile" "c" | ||||||
|  |      "-image" "i" | ||||||
|  |      "-nocolor" "n" | ||||||
|  |      "-color" "N" | ||||||
|  |      "-library" "l" | ||||||
|  |      "-lint-warn" "w" | ||||||
|  |      "-lint-error" "x"}) | ||||||
|  |  | ||||||
|   # Flag handlers |   # Flag handlers | ||||||
|   (def handlers |   (def handlers | ||||||
|     {"h" (fn [&] |     {"h" (fn [&] | ||||||
| @@ -4027,25 +4049,25 @@ | |||||||
|            (print |            (print | ||||||
|              ``` |              ``` | ||||||
|              Options are: |              Options are: | ||||||
|                -h : Show this help |                --help (-h)             : Show this help | ||||||
|                -v : Print the version string |                --version (-v)          : Print the version string | ||||||
|                -s : Use raw stdin instead of getline like functionality |                --stdin (-s)            : Use raw stdin instead of getline like functionality | ||||||
|                -e code : Execute a string of janet |                --eval (-e) code        : Execute a string of janet | ||||||
|                -E code arguments... : Evaluate an expression as a short-fn with arguments |                --expression (-E) code arguments... : Evaluate an expression as a short-fn with arguments | ||||||
|                -d : Set the debug flag in the REPL |                --debug (-d)            : Set the debug flag in the REPL | ||||||
|                -r : Enter the REPL after running all scripts |                --repl (-r)             : Enter the REPL after running all scripts | ||||||
|                -R : Disables loading profile.janet when JANET_PROFILE is present |                --noprofile (-R)        : Disables loading profile.janet when JANET_PROFILE is present | ||||||
|                -p : Keep on executing if there is a top-level error (persistent) |                --persistent (-p)       : Keep on executing if there is a top-level error (persistent) | ||||||
|                -q : Hide logo (quiet) |                --quiet (-q)            : Hide logo (quiet) | ||||||
|                -k : Compile scripts but do not execute (flycheck) |                --flycheck (-k)         : Compile scripts but do not execute (flycheck) | ||||||
|                -m syspath : Set system path for loading global modules |                --syspath (-m) syspath  : Set system path for loading global modules | ||||||
|                -c source output : Compile janet source code into an image |                --compile (-c) source output : Compile janet source code into an image | ||||||
|                -i : Load the script argument as an image file instead of source code |                --image (-i)            : Load the script argument as an image file instead of source code | ||||||
|                -n : Disable ANSI color output in the REPL |                --nocolor (-n)          : Disable ANSI color output in the REPL | ||||||
|                -N : Enable ANSI color output in the REPL |                --color (-N)            : Enable ANSI color output in the REPL | ||||||
|                -l lib : Use a module before processing more arguments |                --library (-l) lib      : Use a module before processing more arguments | ||||||
|                -w level : Set the lint warning level - default is "normal" |                --lint-warn (-w) level  : Set the lint warning level - default is "normal" | ||||||
|                -x level : Set the lint error level - default is "none" |                --lint-error (-x) level : Set the lint error level - default is "none" | ||||||
|                --                      : Stop handling options |                --                      : Stop handling options | ||||||
|              ```) |              ```) | ||||||
|            (os/exit 0) |            (os/exit 0) | ||||||
| @@ -4090,8 +4112,8 @@ | |||||||
|      "R" (fn [&] (setdyn *profilepath* nil) 1)}) |      "R" (fn [&] (setdyn *profilepath* nil) 1)}) | ||||||
|  |  | ||||||
|   (defn- dohandler [n i &] |   (defn- dohandler [n i &] | ||||||
|     (def h (in handlers n)) |     (def h (in handlers (get long-to-short n n))) | ||||||
|     (if h (h i) (do (print "unknown flag -" n) ((in handlers "h"))))) |     (if h (h i handlers) (do (print "unknown flag -" n) ((in handlers "h"))))) | ||||||
|  |  | ||||||
|   # Process arguments |   # Process arguments | ||||||
|   (var i 0) |   (var i 0) | ||||||
|   | |||||||
| @@ -69,7 +69,7 @@ JanetModule janet_native(const char *name, const uint8_t **error) { | |||||||
|             host.minor < modconf.minor || |             host.minor < modconf.minor || | ||||||
|             host.bits != modconf.bits) { |             host.bits != modconf.bits) { | ||||||
|         char errbuf[128]; |         char errbuf[128]; | ||||||
|         sprintf(errbuf, "config mismatch - host %d.%.d.%d(%.4x) vs. module %d.%d.%d(%.4x)", |         snprintf(errbuf, sizeof(errbuf), "config mismatch - host %d.%.d.%d(%.4x) vs. module %d.%d.%d(%.4x)", | ||||||
|                  host.major, |                  host.major, | ||||||
|                  host.minor, |                  host.minor, | ||||||
|                  host.patch, |                  host.patch, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose