mirror of
https://github.com/jwetzell/aas-js.git
synced 2026-08-12 08:03:38 +00:00
add yaml output option
This commit is contained in:
Generated
+2
-2
@@ -5952,7 +5952,6 @@
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz",
|
||||
"integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
@@ -6005,7 +6004,8 @@
|
||||
"commander": "^11.1.0",
|
||||
"fast-xml-parser": "^4.3.2",
|
||||
"serialport": "^12.0.0",
|
||||
"ws": "^8.14.2"
|
||||
"ws": "^8.14.2",
|
||||
"yaml": "^2.3.4"
|
||||
},
|
||||
"bin": {
|
||||
"aas-cli": "index.js"
|
||||
|
||||
@@ -6,7 +6,7 @@ const { writeFileSync } = require('fs');
|
||||
const { program, Option } = require('commander');
|
||||
const { WebSocketServer } = require('ws');
|
||||
const { XMLBuilder } = require('fast-xml-parser');
|
||||
|
||||
const { stringify: yamlify } = require('yaml');
|
||||
const packageInfo = require('./package.json');
|
||||
|
||||
program.name(packageInfo.name);
|
||||
@@ -14,7 +14,7 @@ program.version(packageInfo.version);
|
||||
program.description('Simple protocol router /s');
|
||||
program.option('-d, --device <serial port path>', 'serialport path');
|
||||
program.option('-o, --output <output file>', 'file to write console info to');
|
||||
program.addOption(new Option('-f, --format <output format>').choices(['json', 'xml']).default('json'));
|
||||
program.addOption(new Option('-f, --format <output format>').choices(['json', 'xml', 'yaml']).default('json'));
|
||||
program.option('--websocket <port>', 'enable websocket server for updates', undefined);
|
||||
program.parse(process.argv);
|
||||
|
||||
@@ -84,6 +84,8 @@ port.on('data', (data) => {
|
||||
xmlBuilder = new XMLBuilder();
|
||||
}
|
||||
outputString = xmlBuilder.build({ console: aasConsole.toJSON() });
|
||||
} else if (options.format === 'yaml') {
|
||||
outputString = yamlify(aasConsole.toJSON());
|
||||
}
|
||||
if (outputString) {
|
||||
writeFileSync(options.output, outputString);
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
"commander": "^11.1.0",
|
||||
"fast-xml-parser": "^4.3.2",
|
||||
"serialport": "^12.0.0",
|
||||
"ws": "^8.14.2"
|
||||
"ws": "^8.14.2",
|
||||
"yaml": "^2.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"pkg": "^5.8.1",
|
||||
|
||||
Reference in New Issue
Block a user