Skip to content

Commit c1148d3

Browse files
committed
feat: support raw for notification
1 parent 37d160f commit c1148d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/modules/msg.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ interface NotificationOptions {
1111
avatar?: boolean
1212
image?: boolean
1313
count?: number
14+
// TODO move to global options
15+
raw?: number
16+
pretty?: number
1417
}
1518

1619
export const msg = createCommand('msg')
1720
.description('display notifications')
1821
.aliases(['message', 'notification'])
22+
.option('-r, --raw', 'output raw data', false)
23+
.option('-p, --pretty', 'format raw data', false)
1924
.option('--no-avatar', 'do not show avatar')
2025
.option('--no-image', 'do not show image')
2126
.option('-c, --count <count>', 'notification max count', '30')
@@ -46,6 +51,13 @@ const showNotifications = async (opts: NotificationOptions) => {
4651

4752
logger.success('Loading notifications done!')
4853

54+
if (opts.raw) {
55+
process.stdout.write(
56+
`${JSON.stringify(notifications, null, opts.pretty ? 2 : 0)}\n`
57+
)
58+
return
59+
}
60+
4961
{
5062
const divider = logger.colors.gray('─'.repeat(process.stdout.columns || 30))
5163

0 commit comments

Comments
 (0)