swipl-wasm 5.1.6 → 5.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -100,7 +100,7 @@ the `.js` file instead.
100
100
 
101
101
  ## Generating an image
102
102
 
103
- Often you will want to bundle a pre-built image of your Prolog file. The easiest way to do this is using the `swipl-generate` command to generate the image. For example in `./examples/generation` the script: `swipl-generate ./max.pl ./dist/max.ts` will generate a file `./dist/max.ts` which contains the image of `./max.pl`. This file can then be imported into your project and used as follows:
103
+ Often you will want to bundle a pre-built image of your Prolog file. The easiest way to do this is using the `swipl-generate` command to generate the image. For example in `./examples/generation` the script: `npx swipl-generate ./max.pl ./dist/max.ts` will generate a file `./dist/max.ts` which contains the image of `./max.pl`. This file can then be imported into your project and used as follows:
104
104
 
105
105
  ```ts
106
106
  import SWIPL from './max';
package/dist/bin/index.js CHANGED
@@ -3,6 +3,18 @@
3
3
  const { generateLoadedImageFile, generateImageFile } = require('../generateImage')
4
4
  const path = require('path');
5
5
 
6
+ function showHelp() {
7
+ console.log(`Usage: swipl-generate <input.pl> <output.ts> [--image-only]
8
+
9
+ Arguments:
10
+ input.pl Prolog source file or HTTP(S) URL
11
+ output.ts Output TypeScript file
12
+
13
+ Options:
14
+ --image-only Generate image data only
15
+ --help Show this help`);
16
+ }
17
+
6
18
  function getPath(pth) {
7
19
  return pth.startsWith('http://') || pth.startsWith('https://')
8
20
  ? pth
@@ -12,6 +24,12 @@ function getPath(pth) {
12
24
  async function mainFunc() {
13
25
  let args = process.argv.slice(2);
14
26
 
27
+ // Check for help flag or no arguments
28
+ if (args.includes('--help') || args.includes('-h') || args.length === 0) {
29
+ showHelp();
30
+ return;
31
+ }
32
+
15
33
  const fn = process.argv.includes('--image-only') ? generateImageFile : generateLoadedImageFile;
16
34
  args = args.filter(elem => elem !== '--image-only');
17
35