{"id":22423291,"url":"https://github.com/prantlf/nomnoml-cli","last_synced_at":"2025-08-01T07:32:09.038Z","repository":{"id":35696480,"uuid":"39973546","full_name":"prantlf/nomnoml-cli","owner":"prantlf","description":"Generates images from nomnoml diagram sources in a NodeJS module or on the command line","archived":false,"fork":false,"pushed_at":"2022-01-30T14:33:22.000Z","size":255,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-02T09:52:04.722Z","etag":null,"topics":["diagram-sources","diagrams","generator","nomnoml","uml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prantlf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-30T21:35:58.000Z","updated_at":"2022-07-29T15:00:42.000Z","dependencies_parsed_at":"2022-09-16T02:51:16.246Z","dependency_job_id":null,"html_url":"https://github.com/prantlf/nomnoml-cli","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fnomnoml-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fnomnoml-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fnomnoml-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fnomnoml-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prantlf","download_url":"https://codeload.github.com/prantlf/nomnoml-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228348371,"owners_count":17905899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagram-sources","diagrams","generator","nomnoml","uml"],"created_at":"2024-12-05T18:09:53.869Z","updated_at":"2024-12-05T18:09:54.467Z","avatar_url":"https://github.com/prantlf.png","language":"JavaScript","readme":"# nomnoml-cli\n\n[![Latest version](https://img.shields.io/npm/v/nomnoml-cli)\n ![Dependency status](https://img.shields.io/librariesio/release/npm/nomnoml-cli)\n](https://www.npmjs.com/package/nomnoml-cli)\n[![codecov](https://codecov.io/gh/prantlf/nomnoml-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/nomnoml-cli)\n[![Code Climate](https://codeclimate.com/github/prantlf/nomnoml-cli/badges/gpa.svg)](https://codeclimate.com/github/prantlf/nomnoml-cli)\n\nGenerates images from [nomnoml](http://www.nomnoml.com/) diagram sources\non the command line and provides a library for a programmatic usage from\n[NodeJS] modules\n\n## Getting Started\n\nMake sure that you have [NodeJS] \u003e= 12 installed.\n\n1. Install [pre-requisites](https://github.com/Automattic/node-canvas/wiki/_pages)\n   of the [node-canvas](https://github.com/Automattic/node-canvas) module depending\n   on your operating system\n\n2. Install the command-line tool and generate a testing image:\n\n```bash\nnpm install -g nomnoml-cli\necho '[nomnoml]is-\u003e[awesome]' | nomnoml \u003e awesome.png\n```\n\nRead the documentation about the [nomnoml source format](https://github.com/skanaar/nomnoml#example)\n\n## Command-Line Usage\n\nThe `nomnoml` script generates a png, jpg, svg or pdf image from the nomnoml source text.\nBoth file names and standard input and output are supported as parameters.\nIf generating the image fails, exit code 1 is returned to the caller.\n\n```text\n$ nomnoml --help\n\n  Usage: nomnoml [option]\n\n  Options:\n\n    -h, --help             output usage information\n    -V, --version          output the version number\n    -i, --input \u003cpath\u003e     file with nomnoml source to read from\n    -o, --output \u003cpath\u003e    file for the image output to write to\n    -f, --format \u003cformat\u003e  output format (png, jpg, svg, pdf)\n    -w, --width \u003cpixels\u003e   width of the canvas to draw on\n    -H, --height \u003cpixels\u003e  height of the canvas to draw on\n\n  The default output format is png. The default canvas size is 640x480 pixels.\n  If the input file is omitted, the source is read from the standard input.\n  If the output file is omitted, the image is written to the standard output.\n\n  Examples:\n\n    $ echo '[nomnoml]is-\u003e[awesome]' | nomnoml \u003e awesome.png\n    $ nomnoml -i source.nomnoml -f svg -o target.svg\n```\n\n## Programmatic Usage\n\nThe main module exports a function which generates the image:\n\n```javascript\nconst generateDiagram = require('nomnoml-cli');\nconst diagram = await generateDiagram(...);\n```\n\nThe function returns a [Promise] to wait for a success or a failure.\n\nThe function expects a nomnoml source text as a `string` or an `options`\nobject with the following supported properties:\n\n* `input`: source to read the nomnoml text from; either a [Stream] or a\n    `string` with the actual nomnoml text\n* `inputFile`: source file path to read the nomnoml source from\n* `output`: target to write the image to; either a [Stream] or a `string`\n    with the file path (undefined by default)\n* `resultType`: type of the object to resolve the promise with if the\n    `output` parameter is not provided ('buffer' or 'stream'; the former\n    is default)\n* `format`: output image format ('png', 'jpg', 'svg' or 'pdf'; the first\n    is default)\n* `width`: canvas width in pixels (640 by default)\n* `height`: canvas height in pixels (480 by default)\n\nEither `input` or `inputFile` has to be provided, otherwise the function\nfails.  If `output` is not provided, the function resolves the promise\nwith a [Buffer] containing the image.  If `output` is provided, the\nfunction returns a promise resolved when the output has been written.\n\n### Code Samples\n\n```javascript\nconst generateDiagram = require('nomnoml-cli');\n\n// Get Buffer with the image\nconst buffer = await generateDiagram('[nomnoml]is-\u003e[awesome]');\n\n// Convert the standard input to standard output\nawait generateDiagram({\n  input: process.stdin,\n  output: process.stdout\n});\n\n// Create a PNG file from a nomnoml source file\nawait generateDiagram({\n  inputFile: 'source.nomnoml',\n  output: 'target.png'\n});\n```\n\n## Notes\n\nContents of other `.nomnoml` files can be imported to the input file using\nthe [`#import` directive](https://github.com/skanaar/nomnoml#directives).\nYou can use it for sharing style definitions or parts of diagrams among\nmultiple diagram sources.\n\n```text\n#import: /usr/local/share/nomnoml/style.nomnoml\n#import: shared/style.nomnoml\n#import: ./sub-diagram.nomnoml\n```\n\nIf the imported file path is relative and starts with `./` or `../`, it will\nbe appended to the path of the \"parent\" file, which the specified file is\nbeing imported to. Otherwise the relative path will be appended to the\ncurrent (executing) directory.\n\nFile import directives are processed recursively. However, a single file can\nbe imported only once. If imported once more, scond and other occurrences\nwill be replaced by an empty string.\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding\nstyle.  Add unit tests for any new or changed functionality. Lint and test\nyour code using Grunt.\n\n## License\n\nCopyright (c) 2015-2022 Ferdinand Prantl\n\nLicensed under the MIT license.\n\n[Buffer]: https://nodejs.org/api/buffer.html\n[NodeJS]: http://nodejs.org/\n[Stream]: https://nodejs.org/api/stream.html\n[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fnomnoml-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprantlf%2Fnomnoml-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fnomnoml-cli/lists"}