infographic-cli 0.3.0 → 0.4.0

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
@@ -12,13 +12,13 @@ Command-line interface for [AntV Infographic](https://github.com/antvis/Infograp
12
12
  # Install
13
13
  npm install -g infographic-cli
14
14
 
15
- # Render from stdin
16
- echo 'infographic list-row-simple-horizontal-arrow
15
+ # Render from string (quickest for testing)
16
+ ifgc -s "infographic list-row-simple-horizontal-arrow
17
17
  data
18
18
  title My First Infographic
19
19
  items
20
20
  - label Step 1
21
- - label Step 2' | ifgc -o output.svg
21
+ - label Step 2" -o output.svg
22
22
 
23
23
  # Render from file
24
24
  ifgc -i input.ifgc -o output.svg
@@ -40,6 +40,13 @@ This installs two commands: `ifgc` (short) and `infographic` (long).
40
40
  ### Basic Rendering
41
41
 
42
42
  ```bash
43
+ # From string (quickest for testing)
44
+ ifgc -s "infographic list-row-simple-horizontal-arrow
45
+ data
46
+ title My Chart
47
+ items
48
+ - label Item 1" -o output.svg
49
+
43
50
  # From file (output defaults to input.svg)
44
51
  ifgc -i input.ifgc
45
52
 
@@ -57,7 +64,8 @@ cat input.ifgc | ifgc -o output.svg
57
64
 
58
65
  | Option | Description |
59
66
  |--------|-------------|
60
- | `-i, --input <file>` | Input .ifgc file (omit to read from stdin) |
67
+ | `-s, --string <content>` | Input .ifgc content as a string |
68
+ | `-i, --input <file>` | Input .ifgc file |
61
69
  | `-o, --output <file>` | Output file (default: input.svg) |
62
70
  | `--background <color>` | Background color (default: transparent) |
63
71
  | `-c, --config <file>` | JSON configuration file |
@@ -4,9 +4,13 @@ import { error, info, success } from '../utils/error.js';
4
4
  import { getInputData } from '../utils/input.js';
5
5
  import { getDefaultOutput, writeOutput } from '../utils/output.js';
6
6
  export async function renderCommand(options) {
7
- const { input, output: userOutput, quiet, config: configFile, theme, } = options;
7
+ const { input, string: stringInput, output: userOutput, quiet, config: configFile, theme, } = options;
8
8
  const log = quiet ? () => { } : info;
9
- // Validate input
9
+ // Validate input - cannot use both input file and string
10
+ if (input && stringInput) {
11
+ error('Cannot use both --input and --string options. Please use one.');
12
+ }
13
+ // Validate input file exists
10
14
  if (input && input !== '-') {
11
15
  try {
12
16
  await fs.access(input);
@@ -39,7 +43,14 @@ export async function renderCommand(options) {
39
43
  output = '/dev/stdout';
40
44
  }
41
45
  // Read input data
42
- const inputData = await getInputData(input && input !== '-' ? input : undefined);
46
+ let inputData;
47
+ if (stringInput) {
48
+ // Convert \n to actual newlines and unescape other escape sequences
49
+ inputData = stringInput.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
50
+ }
51
+ else {
52
+ inputData = await getInputData(input && input !== '-' ? input : undefined);
53
+ }
43
54
  if (!inputData.trim()) {
44
55
  error('No input data provided');
45
56
  }
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ program
14
14
  // Main options (render by default, like mmdc)
15
15
  program
16
16
  .option('-i, --input <file>', 'Input .ifgc file (omit to read from stdin)')
17
+ .option('-s, --string <content>', 'Input .ifgc content as a string (use \\n for newlines)')
17
18
  .option('-o, --output <file>', 'Output file (default: input file with .svg extension)')
18
19
  .option('--background <color>', 'Background color (default: transparent)', 'transparent')
19
20
  .option('-c, --config <file>', 'JSON configuration file')
@@ -1,5 +1,6 @@
1
1
  export interface RenderOptions {
2
2
  input?: string;
3
+ string?: string;
3
4
  output?: string;
4
5
  background?: string;
5
6
  quiet?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infographic-cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Command-line interface for AntV Infographic",
5
5
  "license": "MIT",
6
6
  "author": "lyw405",