Skip to content

Commit d26d51e

Browse files
authored
Merge pull request #392 from postmanlabs/issue-186
Add ` as line continuation delimiter for curl
2 parents 795cff2 + d111171 commit d26d51e

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

codegens/curl/lib/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ self = module.exports = {
181181
{
182182
name: 'Line continuation character',
183183
id: 'lineContinuationCharacter',
184-
availableOptions: ['\\', '^'],
184+
availableOptions: ['\\', '^', '`'],
185185
type: 'enum',
186186
default: '\\',
187187
description: 'Set a character used to mark the continuation of a statement on the next line ' +
188-
'(generally, \\ for OSX/Linux, ^ for Windows)'
188+
'(generally, \\ for OSX/Linux, ^ for Windows cmd and ` for Powershell)'
189189
},
190190
{
191191
name: 'Quote Type',

codegens/curl/test/unit/convert.test.js

+53
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,59 @@ describe('curl convert function', function () {
7676
});
7777
});
7878

79+
it('should return snippet with backslash(\\) as line continuation ' +
80+
'character for multiline code generation by default', function () {
81+
request = new sdk.Request({
82+
'method': 'POST',
83+
'header': [],
84+
'body': {
85+
'mode': 'raw',
86+
'raw': ''
87+
}
88+
});
89+
options = {
90+
multiLine: true
91+
};
92+
convert(request, options, function (error, snippet) {
93+
if (error) {
94+
expect.fail(null, null, error);
95+
}
96+
snippetArray = snippet.split('\n');
97+
// Ignoring the last line as there is no line continuation character at last line
98+
for (var i = 0; i < snippetArray.length - 1; i++) {
99+
line = snippetArray[i];
100+
expect(line.charAt(line.length - 1)).to.equal('\\');
101+
}
102+
});
103+
});
104+
105+
it('should return snippet with backtick(`) as line continuation ' +
106+
'character for multiline code generation', function () {
107+
request = new sdk.Request({
108+
'method': 'POST',
109+
'header': [],
110+
'body': {
111+
'mode': 'raw',
112+
'raw': ''
113+
}
114+
});
115+
options = {
116+
multiLine: true,
117+
lineContinuationCharacter: '`'
118+
};
119+
convert(request, options, function (error, snippet) {
120+
if (error) {
121+
expect.fail(null, null, error);
122+
}
123+
snippetArray = snippet.split('\n');
124+
// Ignoring the last line as there is no line continuation character at last line
125+
for (var i = 0; i < snippetArray.length - 1; i++) {
126+
line = snippetArray[i];
127+
expect(line.charAt(line.length - 1)).to.equal('`');
128+
}
129+
});
130+
});
131+
79132
it('should parse header with string value properly', function () {
80133
request = new sdk.Request({
81134
'method': 'POST',

0 commit comments

Comments
 (0)