Skip to content

Commit a7d7b02

Browse files
committed
💄 Update output format.
1 parent d1722c4 commit a7d7b02

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/buildPath.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function buildPath(url, configFile = "./.api-to-go.yml") {
2020

2121
function _buildPath(url, configFile) {
2222
const hostCfg = loadConfig(url, configFile)
23-
let ret ={
23+
let ret = {
2424
pathname: url.pathname,
2525
pathFormat: null,
2626
replacedPath: url.pathname,
@@ -61,7 +61,6 @@ function _replacePath(pathname, format) {
6161
if (replacedArr.length === 0) return
6262

6363
const replacedPath = replacedArr.join("/")
64-
console.log(`Format: ${format}`)
6564
return {
6665
pathname: pathname,
6766
pathFormat: format,

src/run.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ function run(urlStr, body, cliOpts) {
3030
const apiUrl = urlStr.replace(/\/$/, '')
3131
url = new URL(apiUrl);
3232
cfg = loadConfig(url, configFile)
33-
if (cfg?.["docs"] !== undefined) {
34-
console.log(`Docs: ${cfg?.["docs"]}`)
35-
}
3633
path = buildPath(url)
37-
console.log(`Request: (${opts.method}) ${url}`)
38-
console.log(`Response: ${res.status} ${res.statusText}`)
34+
35+
console.log(`API:`)
36+
if (cfg?.["docs"] !== undefined) console.log(` Docs: ${cfg?.["docs"]}`)
37+
if (path.path.pathFormat) console.log(` Format: ${path.path.pathFormat}`)
38+
console.log(` Request: ${opts.method} ${url}`)
39+
console.log(` Response: ${res.status} ${res.statusText}`)
3940

4041
comment = buildComment(url, path, opts.method, res)
4142
return res.json()
@@ -61,8 +62,8 @@ function write(json, path, content) {
6162
});
6263
console.log()
6364
console.log("Saved:")
64-
console.log(` ${path.jsonFilePath}`)
65-
console.log(` ${path.goFilePath}`)
65+
console.log(` Struct: ${path.goFilePath}`)
66+
console.log(` Payload: ${path.jsonFilePath}`)
6667
}
6768

6869
function buildOpts(body, cliOpts) {
@@ -112,12 +113,12 @@ function buildComment(url, path, method, res) {
112113
let comment = ""
113114
const cfg = loadConfig(url, configFile)
114115
if (cfg?.["docs"] !== undefined) {
115-
comment += `\n// Docs: ${cfg?.["docs"]}`
116+
comment += `\n// Docs: ${cfg?.["docs"]}`
116117
}
117118
if (path.path.pathFormat) {
118-
comment += `\n// Format: ${path.path.pathFormat}`
119+
comment += `\n// Format: ${path.path.pathFormat}`
119120
}
120-
comment += `\n// Request: (${method}) ${url.href}`
121+
comment += `\n// Request: ${method} ${url.href}`
121122
comment += `\n// Response: ${res.status} ${res.statusText}`
122123
return `${comment}\n//\n`
123124
}

0 commit comments

Comments
 (0)