forked from hyperjumptech/monika
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Separate flag handlers (hyperjumptech#1277)
* refactor: combine all the flags related code into a file * refactor: combine handle for logs, flush, and summary flag into one file * refactor: replace magic numbers with constant * refactor: remove unnecessary code * test: adjust test
- Loading branch information
1 parent
651cdbe
commit 95e46b4
Showing
14 changed files
with
633 additions
and
610 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,22 @@ | ||
import { ux } from '@oclif/core' | ||
import { flushAllLogs } from './history' | ||
import { getContext } from '../../context' | ||
import { log } from '../../utils/pino' | ||
import { flushAllLogs, openLogfile } from './history' | ||
|
||
export async function flush(isForce: boolean): Promise<void> { | ||
if (isForce) { | ||
await flushAllLogs() | ||
log.info('Records flushed, thank you.') | ||
export async function flush(): Promise<void> { | ||
if (!getContext().flags.force) { | ||
const answer = await ux.ux.prompt( | ||
'Are you sure you want to flush all logs in monika-logs.db (Y/n)?' | ||
) | ||
|
||
return | ||
} | ||
|
||
const ans = await ux.ux.prompt( | ||
'Are you sure you want to flush all logs in monika-logs.db (Y/n)?' | ||
) | ||
|
||
if (ans === 'Y') { | ||
await flushAllLogs() | ||
log.info('Records flushed, thank you.') | ||
if (answer !== 'Y') { | ||
log.info('Cancelled. Thank you.') | ||
|
||
return | ||
return | ||
} | ||
} | ||
|
||
log.info('Cancelled. Thank you.') | ||
await openLogfile() | ||
await flushAllLogs() | ||
log.info('Records flushed, thank you.') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.