Skip to content

Commit

Permalink
feat(command): run add noConsoleClear flag option to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu committed Jun 10, 2024
1 parent d5db3ef commit c92ebe4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/lib/run-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface IRunScriptOptions {
newChat?: boolean,
agentDirs?: string[],
theme?: any,
noConsoleClear?: boolean,
}

function logUpdate(...text: string[]) {
Expand Down Expand Up @@ -143,7 +144,7 @@ export async function runScript(filename: string, options: IRunScriptOptions) {
try {
await runtime.run(options.data)
} finally {
if (!isSilence) {logUpdate.clear()}
if (!isSilence && !options.noConsoleClear) {logUpdate.clear()}
}

let result = runtime.result
Expand Down Expand Up @@ -222,7 +223,7 @@ export async function runScript(filename: string, options: IRunScriptOptions) {
const what = error.data?.what ? ':'+error.data.what : ''
input.write(colors.magentaBright(`<${error.name+what}>`))
} finally {
if (!isSilence) {logUpdate.clear()}
if (!isSilence && !options.noConsoleClear) {logUpdate.clear()}
}
if (result) {
if (typeof result !== 'string') { result = ux.colorizeJson(result, {pretty: true, theme: options.theme?.json})}
Expand Down
3 changes: 2 additions & 1 deletion src/oclif/commands/run/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cj from 'color-json'
import {Args} from '@oclif/core'
import {Args, Flags} from '@oclif/core'
import { parseJsJson } from '@isdk/ai-tool'
import { LogLevelMap, logLevel } from '@isdk/ai-tool-agent'

Expand Down Expand Up @@ -30,6 +30,7 @@ export default class RunScript extends AICommand {
static flags = {
...AICommand.flags,
...AICommonFlags,
'noConsoleClear': Flags.boolean({description: 'disable console clear, debug purpose'}),
}

async run(): Promise<any> {
Expand Down

0 comments on commit c92ebe4

Please sign in to comment.