Skip to content

Commit

Permalink
add revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahsonder committed Jun 28, 2024
1 parent 4854b54 commit 3e7a609
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 11 additions & 3 deletions docs/docs/06-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,23 @@ The output is an SVG image generated by MemoryViz and the image is saved in the

Below are optional arguments used to specify the way in which the SVG image is generated.

#### `--height` and `--width`
### `--width`

Specifies the height and width of the generated SVG.
Specifies the width of the generated SVG.

```console
$ npx memory-viz <path-to-file> --width=700
```

#### `--roughjs_config`
### `--height`

Specifies the height of the generated SVG.

```console
$ npx memory-viz <path-to-file> --height=700
```

### `--roughjs_config`

Specifies the style of the generated SVG. Please refer to the [Rough.js documentation](https://github.com/rough-stuff/rough/wiki#options) for available options.

Expand Down
12 changes: 3 additions & 9 deletions memory-viz/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ const { draw } = require("memory-viz");
const { program } = require("commander");

function parseRoughjsConfig(input) {
let config = {};
const pairs = input.split(",");

pairs.forEach((pair) => {
const [key, val] = pair.split("=");
config[key] = val;
});

return config;
const keyValuePairs = pairs.map((pair) => pair.split("="));
return Object.fromEntries(keyValuePairs);
}

program
Expand All @@ -29,7 +23,7 @@ program
.option("--height <value>", "height of generated SVG")
.option(
"--roughjs-config <key1=value1,key2=value2,...>",
"various options to configure how the SVG is drawn" +
"options to configure how the SVG is drawn" +
" - refer to rough.js documentation for available options",
parseRoughjsConfig
);
Expand Down

0 comments on commit 3e7a609

Please sign in to comment.