Git Product home page Git Product logo

cli's Introduction

NPM version Linux MacOS Windows

wavedrom-cli

WaveDrom command-line interface

Usage

Install

Requires nodejs v14+

npm i wavedrom-cli -g

Export SVG

wavedrom-cli -i mywave.json5 -s mywave.svg

Export PNG

wavedrom-cli -i mywave.json5 -p mywave.png

Export with Inkscape

Inkscape is awesome SVG editor that can be used to convert SVG to many other formats: PDF, PS, EPS, EMF, WMF, PNG. etc. It can be chained with wavedrom-cli to output those formats. Here is an example:

wavedrom-cli -i mywave.json5 | inkscape -p --export-filename=mywave.pdf

Options

  --input, -i  path to the source                                     [required]
  --svg, -s    path to the generated SVG
  --png, -p    path to the generated PNG
  --version    Show version number                                     [boolean]
  --help       Show help                                               [boolean]

License

MIT LICENSE.

cli's People

Contributors

drom avatar gmlarumbe avatar jwcxz avatar k4zuki avatar witchard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

working offline

As far as I understood, it is not possible to run 'phantomjs wavedrom-cli.js' without have internet access.
Is there a way to have it working or installed without the need of an connection when building the wavefrom?

Javascript Immediately Invoked Function Expression (IIFE) is not supported

Wavedrom GUI supports IIFE, but wavedrom-cli does not. It would be good to have better compatibility between the 2 tools, to avoid having to convert existing .js files to .json5.

This is the output when trying to convert .js files:

Error:
SyntaxError: JSON5: invalid character '(' at 1:1
    at syntaxError (C:\Users\XYZI\Apps_DONT_DELETE\node-v18.15.0-win-x64\node_modules\wavedrom-cli\node_modules\json5\lib\parse.js:1110:17)

Expected result:
IIFE would be evaluated first, then its returned result would be used to create the waveform.

text disappears in png

The wavejson

{"signal": [{"name": "x[0]", "wave": "x01010101."}, {"name": "x[1]", "wave": "x0.1.0.1.."}, {"name": "x[2]", "wave": "x0...1...."}, {"name": "y[0]", "wave": "x10......."}, {"name": "y[1]", "wave": "x010......"}, {"name": "y[2]", "wave": "x0.10....."}, {"name": "y[3]", "wave": "x0..10...."}, {"name": "y[4]", "wave": "x0...10..."}, {"name": "y[5]", "wave": "x0....10.."}, {"name": "y[6]", "wave": "x0.....10."}, {"name": "y[7]", "wave": "x0......1."}, {"name": "x", "wave": "=========.", "data": ["x", 0, 1, 2, 3, 4, 5, 6, 7]}, {"name": "y", "wave": "=========.", "data": ["x", 1, 2, 4, 8, 16, 32, 64, 128]}]}

should look like (in https://wavedrom.com/editor.html):

image

while the output from cli is:

wave

Error from wavedrom format to png

When i attempted to convert wavedrom format to png, there is an error.

Error: Cannot find module '../build/Release/canvas.node'
Require stack:

  • /usr/lib/node_modules/wavedrom-cli/node_modules/canvas/lib/bindings.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/canvas/lib/canvas.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/canvas/index.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/utils.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/generated/MouseEvent.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/interfaces.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/browser/Window.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/api.js
  • /usr/lib/node_modules/wavedrom-cli/node_modules/svg2img/index.js
  • /usr/lib/node_modules/wavedrom-cli/wavedrom-cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (/usr/lib/node_modules/wavedrom-cli/node_modules/canvas/lib/bindings.js:3:18)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/usr/lib/node_modules/wavedrom-cli/node_modules/canvas/lib/bindings.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/canvas/lib/canvas.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/canvas/index.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/utils.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/generated/MouseEvent.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/living/interfaces.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/jsdom/browser/Window.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/jsdom/lib/api.js',
    '/usr/lib/node_modules/wavedrom-cli/node_modules/svg2img/index.js',
    '/usr/lib/node_modules/wavedrom-cli/wavedrom-cli.js'
    How can fix it? Thanks!

Read from stdin when filename is '-'

I need a way to pipe from stdin to wavedrom-cli. I was happy when I found the old issue with a fix for this. Unfortunately it seems that this fix was later removed again. Is there any plan to add support for this again?

need 'narrow' skin for CLI

I notice there's no 'narrow' skin available to the CLI flow by default. Could we get access to it?
I can try to look myself at the code but I'm a little ignorant as to how the CLI is built so it might take me a while. :)

CLI hangs

I followed the steps below:

  1. Install PhantomJS version 2.0 from http://phantomjs.org/download.html
  2. Install version 4.2.4 from https://nodejs.org/en/download/ to obtain the npm.
  3. Run npm i wavedrom-cli --save-dev
  4. Run phantomjs node_modules\.bin\wavedrom -i path\to\sample.json -p sample.png -s sample.svg

The phantomjs command never terminates (I waited for more than 30mins).

I am using Windows 7 64 bit operating system.

cli version doesn't render signal groupings

The signal groupings is made in javascript by grouping signals into an array, and shows up in GUI wavedrom with a bracket and sideways text on the left side.

In the CLI version I don't see any of the text and brackets on the left side for code that renders properly in the GUI wavedrom.

Error when trying to run `wavedrom` CLI

Hello,

I ended up discovering this CLI form of wavedrom from this issue: wavedrom/wavedrom#161.

I did npm i -g wavedrom-cli --save-dev and it installed fine.

My npm version is 6.1.0.

When I typed just wavedrom, I got this error:

/home/kmodi/stowed/bin/wavedrom: line 1: /adlib: is a directory
/home/kmodi/stowed/bin/wavedrom: line 2: use strict: command not found
/home/kmodi/stowed/bin/wavedrom: line 4: syntax error near unexpected token `('
/home/kmodi/stowed/bin/wavedrom: line 4: `var fs = require('fs'),'`

Typing wavedrom -h, wavedrom --help gave the same error.

Increase resolution of PNG file?

Hi is there a way to configure the resolution of the PNG file? It looks like svg2img has a dpi option. I was wondering if the PNG export can use 300dpi export quality through a cmdline option?

Error when running wavefrom cli

When I try to run the wavedrom cli, I get this error:

npx wavedrom-cli -i test.json -s test.svg
Unexpected token {

The file test.json is attached here: test.txt (filename changed since github doesn't like json files.

This file works in the online editor and was saved from there.

Color disappears in svg

When setting svg as the format for our wavedrom diagrams using [wavedrom, ,svg], the type attribute of bitfields (which determines background color) is ignored and the bitfield backgrounds renders grey.

Here's an example:
[wavedrom, ,svg]
....
{reg: [
{bits: 7, name: 'opcode', type: 8, attr: ['7','AMO','AMO','AMO','AMO','AMO','AMO','AMO']},
{bits: 5, name: 'rd', type: 2, attr: ['5','dest','dest','dest','dest','dest','dest','dest']},
{bits: 3, name: 'funct3', type: 8, attr: ['3','width','width','width','width','width','width','width']},
{bits: 5, name: 'rs1', type: 4, attr: ['5','addr','addr','addr','addr','addr','addr','addr']},
{bits: 5, name: 'rs2', type: 4, attr: ['5','src','src','src','src','src','src','src']},
{bits: 1, name: 'rl', type: 8, attr: ['1']},
{bits: 1, name: 'aq', type: 8, attr: ['1']},
{bits: 6, name: 'funct5', type: 8, attr: ['5','AMOSWAP.W/D', 'AMOADD.W/D', 'AMOAND.W/D', 'AMOOR.W/D', 'AMOXOR.W/D', 'AMOMAX[U].W/D','AMOMIN[U].W/D']},
], config: {bits: 32}}
....

Note that if I change svg to png the colored background works.

Also, if you paste the code above into https://wavedrom.com/editor.html without the [wavedrom, ,svg] line, or the two .... lines you can see how the colors should render.

Can't export logic circuit diagram as PNG

When trying to convert the following JSON file as PNG using wavedrom-cli -i test.json -p test.png I get the errors I've pasted below:

{ assign:[
  ["out",
    ["|",
      ["&", ["~", "a"], "b"],
      ["&", ["~", "b"], "a"]
    ]
  ]
]}
/usr/local/lib/node_modules/wavedrom-cli/node_modules/svg2img/index.js:64
            imgBuffer = pngData.asPng();
                                ^

TypeError: Cannot read properties of undefined (reading 'asPng')
    at /usr/local/lib/node_modules/wavedrom-cli/node_modules/svg2img/index.js:64:33
    at loadSVGContent (/usr/local/lib/node_modules/wavedrom-cli/node_modules/svg2img/index.js:75:9)
    at svg2img (/usr/local/lib/node_modules/wavedrom-cli/node_modules/svg2img/index.js:24:5)
    at /usr/local/lib/node_modules/wavedrom-cli/wavedrom-cli.js:47:7
    at /usr/local/lib/node_modules/wavedrom-cli/node_modules/graceful-fs/graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3)

I've tested on both WSL and Windows using version 3.1.1 of wavedrom-cli. On WSL I've tested with the versions 12, 19, and 20 of node. On Windows I've only tested using version 20 of node. When exporting as SVG everything works fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.