Skip to content

Commit 0cb3b2d

Browse files
committed
Update
1 parent 68bef7c commit 0cb3b2d

File tree

2 files changed

+36
-12
lines changed
  • src
    • ResourceManager/Compute/Commands.Compute/Generated
    • ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation

2 files changed

+36
-12
lines changed

src/ResourceManager/Compute/Commands.Compute/Generated/cli.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,17 @@ exports.init = function (cli) {
8686
.option('--operation <operation>', $('The JSON patch operation: add, remove, or replace.'))
8787
.option('--path <path>', $('The JSON data path, e.g.: \"foo/1\".'))
8888
.option('--value <value>', $('The JSON value.'))
89-
.execute(function (parameterFile, operation, path, value, options, _) {
89+
.option('--parse', $('Parse the JSON value to object.'))
90+
.execute(function (parameterFile, operation, path, value, parse, options, _) {
9091
console.log(options.parameterFile);
9192
console.log(options.operation);
9293
console.log(options.path);
9394
console.log(options.value);
95+
console.log(options.parse);
96+
if (options.parse) {
97+
options.value = JSON.parse(options.value);
98+
}
99+
console.log(options.value);
94100
console.log("=====================================");
95101
console.log("Reading file content from: \"" + options.parameterFile + "\"");
96102
console.log("=====================================");
@@ -99,13 +105,13 @@ exports.init = function (cli) {
99105
console.log("JSON object:");
100106
console.log(JSON.stringify(parametersObj));
101107
if (options.operation == 'add') {
102-
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: JSON.parse(options.value)}]);
108+
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: options.value}]);
103109
}
104110
else if (options.operation == 'remove') {
105111
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path}]);
106112
}
107113
else if (options.operation == 'replace') {
108-
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: JSON.parse(options.value)}]);
114+
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: options.value}]);
109115
}
110116
var updatedContent = JSON.stringify(parametersObj);
111117
console.log("=====================================");
@@ -291,11 +297,17 @@ exports.init = function (cli) {
291297
.option('--operation <operation>', $('The JSON patch operation: add, remove, or replace.'))
292298
.option('--path <path>', $('The JSON data path, e.g.: \"foo/1\".'))
293299
.option('--value <value>', $('The JSON value.'))
294-
.execute(function (parameterFile, operation, path, value, options, _) {
300+
.option('--parse', $('Parse the JSON value to object.'))
301+
.execute(function (parameterFile, operation, path, value, parse, options, _) {
295302
console.log(options.parameterFile);
296303
console.log(options.operation);
297304
console.log(options.path);
298305
console.log(options.value);
306+
console.log(options.parse);
307+
if (options.parse) {
308+
options.value = JSON.parse(options.value);
309+
}
310+
console.log(options.value);
299311
console.log("=====================================");
300312
console.log("Reading file content from: \"" + options.parameterFile + "\"");
301313
console.log("=====================================");
@@ -304,13 +316,13 @@ exports.init = function (cli) {
304316
console.log("JSON object:");
305317
console.log(JSON.stringify(parametersObj));
306318
if (options.operation == 'add') {
307-
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: JSON.parse(options.value)}]);
319+
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: options.value}]);
308320
}
309321
else if (options.operation == 'remove') {
310322
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path}]);
311323
}
312324
else if (options.operation == 'replace') {
313-
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: JSON.parse(options.value)}]);
325+
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: options.value}]);
314326
}
315327
var updatedContent = JSON.stringify(parametersObj);
316328
console.log("=====================================");
@@ -610,11 +622,17 @@ exports.init = function (cli) {
610622
.option('--operation <operation>', $('The JSON patch operation: add, remove, or replace.'))
611623
.option('--path <path>', $('The JSON data path, e.g.: \"foo/1\".'))
612624
.option('--value <value>', $('The JSON value.'))
613-
.execute(function (parameterFile, operation, path, value, options, _) {
625+
.option('--parse', $('Parse the JSON value to object.'))
626+
.execute(function (parameterFile, operation, path, value, parse, options, _) {
614627
console.log(options.parameterFile);
615628
console.log(options.operation);
616629
console.log(options.path);
617630
console.log(options.value);
631+
console.log(options.parse);
632+
if (options.parse) {
633+
options.value = JSON.parse(options.value);
634+
}
635+
console.log(options.value);
618636
console.log("=====================================");
619637
console.log("Reading file content from: \"" + options.parameterFile + "\"");
620638
console.log("=====================================");
@@ -623,13 +641,13 @@ exports.init = function (cli) {
623641
console.log("JSON object:");
624642
console.log(JSON.stringify(parametersObj));
625643
if (options.operation == 'add') {
626-
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: JSON.parse(options.value)}]);
644+
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: options.value}]);
627645
}
628646
else if (options.operation == 'remove') {
629647
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path}]);
630648
}
631649
else if (options.operation == 'replace') {
632-
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: JSON.parse(options.value)}]);
650+
jsonpatch.apply(parametersObj, [{op: options.operation, path: options.path, value: options.value}]);
633651
}
634652
var updatedContent = JSON.stringify(parametersObj);
635653
console.log("=====================================");

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/RunCodeGeneration.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,11 +1826,17 @@ ${cmdlet_partial_class_code}
18261826
$cli_op_code_content += " .option('--operation <operation>', `$('The JSON patch operation: add, remove, or replace.'))" + $new_line_str;
18271827
$cli_op_code_content += " .option('--path <path>', `$('The JSON data path, e.g.: \`"foo/1\`".'))" + $new_line_str;
18281828
$cli_op_code_content += " .option('--value <value>', `$('The JSON value.'))" + $new_line_str;
1829-
$cli_op_code_content += " .execute(function (parameterFile, operation, path, value, options, _) {" + $new_line_str;
1829+
$cli_op_code_content += " .option('--parse', `$('Parse the JSON value to object.'))" + $new_line_str;
1830+
$cli_op_code_content += " .execute(function (parameterFile, operation, path, value, parse, options, _) {" + $new_line_str;
18301831
$cli_op_code_content += " console.log(options.parameterFile);" + $new_line_str;
18311832
$cli_op_code_content += " console.log(options.operation);" + $new_line_str;
18321833
$cli_op_code_content += " console.log(options.path);" + $new_line_str;
18331834
$cli_op_code_content += " console.log(options.value);" + $new_line_str;
1835+
$cli_op_code_content += " console.log(options.parse);" + $new_line_str;
1836+
$cli_op_code_content += " if (options.parse) {" + $new_line_str;
1837+
$cli_op_code_content += " options.value = JSON.parse(options.value);" + $new_line_str;
1838+
$cli_op_code_content += " }" + $new_line_str;
1839+
$cli_op_code_content += " console.log(options.value);" + $new_line_str;
18341840
$cli_op_code_content += " console.log(`"=====================================`");" + $new_line_str;
18351841
$cli_op_code_content += " console.log(`"Reading file content from: \`"`" + options.parameterFile + `"\`"`");" + $new_line_str;
18361842
$cli_op_code_content += " console.log(`"=====================================`");" + $new_line_str;
@@ -1839,13 +1845,13 @@ ${cmdlet_partial_class_code}
18391845
$cli_op_code_content += " console.log(`"JSON object:`");" + $new_line_str;
18401846
$cli_op_code_content += " console.log(JSON.stringify(${cli_param_name}Obj));" + $new_line_str;
18411847
$cli_op_code_content += " if (options.operation == 'add') {" + $new_line_str;
1842-
$cli_op_code_content += " jsonpatch.apply(${cli_param_name}Obj, [{op: options.operation, path: options.path, value: JSON.parse(options.value)}]);" + $new_line_str;
1848+
$cli_op_code_content += " jsonpatch.apply(${cli_param_name}Obj, [{op: options.operation, path: options.path, value: options.value}]);" + $new_line_str;
18431849
$cli_op_code_content += " }" + $new_line_str;
18441850
$cli_op_code_content += " else if (options.operation == 'remove') {" + $new_line_str;
18451851
$cli_op_code_content += " jsonpatch.apply(${cli_param_name}Obj, [{op: options.operation, path: options.path}]);" + $new_line_str;
18461852
$cli_op_code_content += " }" + $new_line_str;
18471853
$cli_op_code_content += " else if (options.operation == 'replace') {" + $new_line_str;
1848-
$cli_op_code_content += " jsonpatch.apply(${cli_param_name}Obj, [{op: options.operation, path: options.path, value: JSON.parse(options.value)}]);" + $new_line_str;
1854+
$cli_op_code_content += " jsonpatch.apply(${cli_param_name}Obj, [{op: options.operation, path: options.path, value: options.value}]);" + $new_line_str;
18491855
$cli_op_code_content += " }" + $new_line_str;
18501856
$cli_op_code_content += " var updatedContent = JSON.stringify(${cli_param_name}Obj);" + $new_line_str;
18511857
$cli_op_code_content += " console.log(`"=====================================`");" + $new_line_str;

0 commit comments

Comments
 (0)