MCPcopy
hub / github.com/adonisjs/core / run

Method run

commands/list/routes.ts:103–165  ·  view source on GitHub ↗

* Execute the command to list application routes. * Creates a formatter with the specified filters and outputs routes * in the requested format (JSON, table, or formatted list).

()

Source from the content-addressed store, hash-verified

101 * in the requested format (JSON, table, or formatted list).
102 */
103 async run() {
104 const router = await this.app.container.make('router')
105 const formatter = new RoutesListFormatter(
106 router,
107 this.ui,
108 {},
109 {
110 ignoreMiddleware: this.ignoreMiddleware,
111 middleware: this.middleware,
112 match: this.match,
113 }
114 )
115
116 /**
117 * Display as JSONL (one JSON object per line).
118 * Auto-selected when running inside an AI agent and no
119 * explicit format flag is provided.
120 */
121 if (this.jsonl || (!this.json && !this.table && this.app.runningInAIAgent)) {
122 const lines = await formatter.formatAsJSONL()
123 for (const line of lines) {
124 this.logger.log(line)
125 }
126 return
127 }
128
129 /**
130 * Display as JSON
131 */
132 if (this.json) {
133 this.logger.log(JSON.stringify(await formatter.formatAsJSON(), null, 2))
134 return
135 }
136
137 /**
138 * Display as a standard table
139 */
140 if (this.table) {
141 const tables = await formatter.formatAsAnsiTable()
142 tables.forEach((table) => {
143 this.logger.log('')
144 if (table.heading) {
145 this.logger.log(table.heading)
146 this.logger.log('')
147 }
148 table.table.render()
149 })
150 return
151 }
152
153 /**
154 * Display as a list
155 */
156 const list = await formatter.formatAsAnsiList()
157 list.forEach((item) => {
158 this.logger.log('')
159 if (item.heading) {
160 this.logger.log(item.heading)

Callers

nothing calls this directly

Calls 6

formatAsJSONLMethod · 0.95
formatAsJSONMethod · 0.95
formatAsAnsiTableMethod · 0.95
formatAsAnsiListMethod · 0.95
makeMethod · 0.80
renderMethod · 0.65

Tested by

no test coverage detected