Skip to content

Commit

Permalink
draft: new response() from prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
midnqp committed Mar 9, 2023
1 parent db17b75 commit c591f51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/handlers/update.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import services from '@src/services/index.js'
import psdk from 'postman-collection'
import { PostmanCli } from '@src/types'
import { Command } from 'commander'
import editor from '@inquirer/editor'
Expand All @@ -14,13 +15,20 @@ export default async function (
const resource = services.resource.getFromNested(co, args)

if (services.response.isResponse(resource)) {
const p = services.response.toPrintable(resource)
const p = services.example.toPrintable(resource)
const str = util.inspect(p, {
colors: false,
maxArrayLength: null,
maxStringLength: null,
depth: 50,
})
const prompt: any = await editor({ default: str, message: '' })

new psdk.Response({
code: prompt.response.code,
responseTime: prompt.response.time,
body: prompt.response.body,
header: [{}],
})
const prompt = await editor({ default: str, message: '' })
console.log(prompt)
}
}
2 changes: 1 addition & 1 deletion src/services/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ export class RequestService {
params: r.url.variables.toObject(),
query: r.url.query.toObject(),
body: r.body?.raw,
$parsedBody,
url: {
path: r.url.getPath({ unresolved: true }),
method: r.method.toLowerCase(),
},
headers: r.headers.toObject(),
$parsedBody,
$parseHint,
}
if (opts.includeGlobalHeaders && opts.headers) {
Expand Down

0 comments on commit c591f51

Please sign in to comment.