Skip to content

Commit 32f93b4

Browse files
committed
chore: add command placeholders
1 parent 69a8850 commit 32f93b4

File tree

2 files changed

+126
-4
lines changed

2 files changed

+126
-4
lines changed

README.md

+46-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
## Features
1414

15-
- 🔍 Modern Debugging & Logging
1615
- 🎨 Rich Colored Output
1716
- ⚡ Performance Tracking
1817
- 📊 Multiple Log Levels
@@ -72,11 +71,54 @@ logger.only(() => {
7271
### CLI
7372

7473
```bash
75-
clarity --verbose
76-
clarity --help
77-
clarity --version
74+
# Watch logs in real-time
75+
clarity watch --level debug --name "parser:*"
76+
clarity watch --json --timestamp
77+
78+
# Log a one-off message
79+
clarity log "Starting deployment" --level info --name "deploy"
80+
81+
# Export logs to a file
82+
clarity export --format json --output logs.json --level error
83+
clarity export --start 2024-01-01 --end 2024-01-31
84+
85+
# Show and follow last N lines
86+
clarity tail --lines 50 --level error --follow
87+
clarity tail --name "api:*"
88+
89+
# Search through logs
90+
clarity search "error connecting to database" --level error
91+
clarity search "deployment" --start 2024-01-01 --case-sensitive
92+
93+
# Clear log history
94+
clarity clear --level debug --before 2024-01-01
95+
clarity clear --name "temp:*"
96+
97+
# Manage configuration
98+
clarity config set --level debug
99+
clarity config list
100+
101+
# Utility commands
102+
clarity --help # Show help information
103+
clarity --version # Show version number
78104
```
79105

106+
All commands support the following common options:
107+
108+
- `--level`: Filter by log level (debug, info, warning, error)
109+
- `--name`: Filter by logger name (supports patterns like "parser:*")
110+
- `--verbose`: Enable verbose output
111+
112+
#### Command Reference
113+
114+
- `watch`: Monitor logs in real-time with filtering and formatting options
115+
- `log`: Send one-off log messages with specified level and name
116+
- `export`: Save logs to a file in various formats with date range filtering
117+
- `tail`: Show and optionally follow the last N lines of logs
118+
- `search`: Search through logs using patterns with date range and case sensitivity options
119+
- `clear`: Clear log history with level, name, and date filtering
120+
- `config`: Manage clarity configuration (get, set, list)
121+
80122
## Configuration
81123

82124
Clarity can be configured using environment variables or global variables in the browser:

bin/cli.ts

+80
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,32 @@ interface LogOptions {
1717
verbose?: boolean
1818
}
1919

20+
interface ExportOptions {
21+
format?: 'json' | 'text'
22+
output?: string
23+
level?: 'debug' | 'info' | 'warning' | 'error'
24+
name?: string
25+
start?: string
26+
end?: string
27+
}
28+
29+
interface TailOptions {
30+
lines?: number
31+
level?: 'debug' | 'info' | 'warning' | 'error'
32+
name?: string
33+
follow?: boolean
34+
}
35+
36+
interface SearchOptions {
37+
pattern: string
38+
level?: 'debug' | 'info' | 'warning' | 'error'
39+
name?: string
40+
start?: string
41+
end?: string
42+
caseSensitive?: boolean
43+
}
44+
45+
// Watch command - for monitoring logs in real-time
2046
// Watch command - for monitoring logs in real-time
2147
cli
2248
.command('watch', 'Watch logs in real-time')
@@ -43,6 +69,60 @@ cli
4369
console.log('Logging message with options:', { message, options })
4470
})
4571

72+
// Export command - for saving logs to a file
73+
cli
74+
.command('export', 'Export logs to a file')
75+
.option('--format <format>', 'Output format (json or text)', { default: 'text' })
76+
.option('--output <file>', 'Output file path')
77+
.option('--level <level>', 'Filter by log level')
78+
.option('--name <name>', 'Filter by logger name')
79+
.option('--start <date>', 'Start date for export (ISO format)')
80+
.option('--end <date>', 'End date for export (ISO format)')
81+
.example('clarity export --format json --output logs.json --level error')
82+
.action(async (options: ExportOptions) => {
83+
// Implementation will go here
84+
console.log('Exporting logs with options:', options)
85+
})
86+
87+
// Tail command - for following the last N lines of logs
88+
cli
89+
.command('tail', 'Show the last N lines of logs')
90+
.option('--lines <n>', 'Number of lines to show', { default: 10 })
91+
.option('--level <level>', 'Filter by log level')
92+
.option('--name <name>', 'Filter by logger name')
93+
.option('--follow', 'Follow log output in real time')
94+
.example('clarity tail --lines 50 --level error --follow')
95+
.action(async (options: TailOptions) => {
96+
// Implementation will go here
97+
console.log('Tailing logs with options:', options)
98+
})
99+
100+
// Search command - for searching through logs
101+
cli
102+
.command('search <pattern>', 'Search through logs')
103+
.option('--level <level>', 'Filter by log level')
104+
.option('--name <name>', 'Filter by logger name')
105+
.option('--start <date>', 'Start date for search (ISO format)')
106+
.option('--end <date>', 'End date for search (ISO format)')
107+
.option('--case-sensitive', 'Enable case-sensitive search')
108+
.example('clarity search "error connecting to database" --level error')
109+
.action(async (pattern: string, options: SearchOptions) => {
110+
// Implementation will go here
111+
console.log('Searching logs with pattern and options:', { pattern, options })
112+
})
113+
114+
// Clear command - for clearing log history
115+
cli
116+
.command('clear', 'Clear log history')
117+
.option('--level <level>', 'Clear specific log level only')
118+
.option('--name <name>', 'Clear specific logger only')
119+
.option('--before <date>', 'Clear logs before date (ISO format)')
120+
.example('clarity clear --level debug --before 2024-01-01')
121+
.action(async (options) => {
122+
// Implementation will go here
123+
console.log('Clearing logs with options:', options)
124+
})
125+
46126
// Config command - for managing configuration
47127
cli
48128
.command('config', 'Manage clarity configuration')

0 commit comments

Comments
 (0)