refactor(file): drop redundant gen wrappers
This commit is contained in:
parent
c97ac8f71c
commit
28fa040e5d
2 changed files with 15 additions and 45 deletions
|
|
@ -17,11 +17,7 @@ const FileSearchCommand = cmd({
|
||||||
}),
|
}),
|
||||||
async handler(args) {
|
async handler(args) {
|
||||||
await bootstrap(process.cwd(), async () => {
|
await bootstrap(process.cwd(), async () => {
|
||||||
const results = await AppRuntime.runPromise(
|
const results = await AppRuntime.runPromise(File.Service.use((svc) => svc.search({ query: args.query })))
|
||||||
Effect.gen(function* () {
|
|
||||||
return yield* File.Service.use((svc) => svc.search({ query: args.query }))
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
process.stdout.write(results.join(EOL) + EOL)
|
process.stdout.write(results.join(EOL) + EOL)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -38,11 +34,7 @@ const FileReadCommand = cmd({
|
||||||
}),
|
}),
|
||||||
async handler(args) {
|
async handler(args) {
|
||||||
await bootstrap(process.cwd(), async () => {
|
await bootstrap(process.cwd(), async () => {
|
||||||
const content = await AppRuntime.runPromise(
|
const content = await AppRuntime.runPromise(File.Service.use((svc) => svc.read(args.path)))
|
||||||
Effect.gen(function* () {
|
|
||||||
return yield* File.Service.use((svc) => svc.read(args.path))
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
process.stdout.write(JSON.stringify(content, null, 2) + EOL)
|
process.stdout.write(JSON.stringify(content, null, 2) + EOL)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -54,11 +46,7 @@ const FileStatusCommand = cmd({
|
||||||
builder: (yargs) => yargs,
|
builder: (yargs) => yargs,
|
||||||
async handler() {
|
async handler() {
|
||||||
await bootstrap(process.cwd(), async () => {
|
await bootstrap(process.cwd(), async () => {
|
||||||
const status = await AppRuntime.runPromise(
|
const status = await AppRuntime.runPromise(File.Service.use((svc) => svc.status()))
|
||||||
Effect.gen(function* () {
|
|
||||||
return yield* File.Service.use((svc) => svc.status())
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
process.stdout.write(JSON.stringify(status, null, 2) + EOL)
|
process.stdout.write(JSON.stringify(status, null, 2) + EOL)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -75,11 +63,7 @@ const FileListCommand = cmd({
|
||||||
}),
|
}),
|
||||||
async handler(args) {
|
async handler(args) {
|
||||||
await bootstrap(process.cwd(), async () => {
|
await bootstrap(process.cwd(), async () => {
|
||||||
const files = await AppRuntime.runPromise(
|
const files = await AppRuntime.runPromise(File.Service.use((svc) => svc.list(args.path)))
|
||||||
Effect.gen(function* () {
|
|
||||||
return yield* File.Service.use((svc) => svc.list(args.path))
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
process.stdout.write(JSON.stringify(files, null, 2) + EOL)
|
process.stdout.write(JSON.stringify(files, null, 2) + EOL)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -74,16 +74,14 @@ export const FileRoutes = lazy(() =>
|
||||||
const type = c.req.valid("query").type
|
const type = c.req.valid("query").type
|
||||||
const limit = c.req.valid("query").limit
|
const limit = c.req.valid("query").limit
|
||||||
const results = await AppRuntime.runPromise(
|
const results = await AppRuntime.runPromise(
|
||||||
Effect.gen(function* () {
|
File.Service.use((svc) =>
|
||||||
return yield* File.Service.use((svc) =>
|
svc.search({
|
||||||
svc.search({
|
query,
|
||||||
query,
|
limit: limit ?? 10,
|
||||||
limit: limit ?? 10,
|
dirs: dirs !== "false",
|
||||||
dirs: dirs !== "false",
|
type,
|
||||||
type,
|
}),
|
||||||
}),
|
),
|
||||||
)
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
return c.json(results)
|
return c.json(results)
|
||||||
},
|
},
|
||||||
|
|
@ -140,11 +138,7 @@ export const FileRoutes = lazy(() =>
|
||||||
),
|
),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const path = c.req.valid("query").path
|
const path = c.req.valid("query").path
|
||||||
const content = await AppRuntime.runPromise(
|
const content = await AppRuntime.runPromise(File.Service.use((svc) => svc.list(path)))
|
||||||
Effect.gen(function* () {
|
|
||||||
return yield* File.Service.use((svc) => svc.list(path))
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
return c.json(content)
|
return c.json(content)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -173,11 +167,7 @@ export const FileRoutes = lazy(() =>
|
||||||
),
|
),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const path = c.req.valid("query").path
|
const path = c.req.valid("query").path
|
||||||
const content = await AppRuntime.runPromise(
|
const content = await AppRuntime.runPromise(File.Service.use((svc) => svc.read(path)))
|
||||||
Effect.gen(function* () {
|
|
||||||
return yield* File.Service.use((svc) => svc.read(path))
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
return c.json(content)
|
return c.json(content)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -199,11 +189,7 @@ export const FileRoutes = lazy(() =>
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const content = await AppRuntime.runPromise(
|
const content = await AppRuntime.runPromise(File.Service.use((svc) => svc.status()))
|
||||||
Effect.gen(function* () {
|
|
||||||
return yield* File.Service.use((svc) => svc.status())
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
return c.json(content)
|
return c.json(content)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue