@portel/cli 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# @portel/cli
|
|
2
|
+
|
|
3
|
+
CLI toolkit for building beautiful terminal applications. Provides formatting, progress indicators, fuzzy matching, and logging utilities.
|
|
4
|
+
|
|
5
|
+
## Part of the Portel Ecosystem
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
9
|
+
│ @portel/cli (this package) │
|
|
10
|
+
│ CLI utilities: formatting, progress, logging │
|
|
11
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
12
|
+
▲
|
|
13
|
+
│
|
|
14
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
15
|
+
│ @portel/mcp │
|
|
16
|
+
│ MCP protocol: client, transport, config │
|
|
17
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
18
|
+
▲
|
|
19
|
+
│
|
|
20
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
21
|
+
│ @portel/photon-core │
|
|
22
|
+
│ Core library: schema extraction, generators, UI │
|
|
23
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
24
|
+
▲
|
|
25
|
+
│
|
|
26
|
+
┌─────────────────────┼─────────────────────┐
|
|
27
|
+
│ │ │
|
|
28
|
+
┌───────┴───────┐ ┌───────┴───────┐ ┌───────┴───────┐
|
|
29
|
+
│ @portel/photon│ │ lumina │ │ @portel/ncp │
|
|
30
|
+
│ CLI + BEAM │ │ REST runtime │ │ MCP orchestr. │
|
|
31
|
+
└───────────────┘ └───────────────┘ └───────────────┘
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Use this package if:** You're building CLI tools and need beautiful output formatting, spinners, or fuzzy matching.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install @portel/cli
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
### Output Formatting
|
|
45
|
+
|
|
46
|
+
Format data as tables, trees, lists, or cards with automatic detection.
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { formatOutput, renderTable, renderTree } from '@portel/cli';
|
|
50
|
+
|
|
51
|
+
// Auto-detect format based on data shape
|
|
52
|
+
formatOutput([{ name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }]);
|
|
53
|
+
|
|
54
|
+
// Explicit formats
|
|
55
|
+
formatOutput(data, 'table'); // Bordered table
|
|
56
|
+
formatOutput(data, 'tree'); // Indented tree
|
|
57
|
+
formatOutput(data, 'list'); // Bullet list
|
|
58
|
+
formatOutput(data, 'json'); // Pretty JSON
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Progress Indicators
|
|
62
|
+
|
|
63
|
+
Show spinners and progress bars for long-running operations.
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { startSpinner, stopProgress, showProgress } from '@portel/cli';
|
|
67
|
+
|
|
68
|
+
// Simple spinner
|
|
69
|
+
startSpinner('Loading...');
|
|
70
|
+
await doWork();
|
|
71
|
+
stopProgress();
|
|
72
|
+
|
|
73
|
+
// With progress updates
|
|
74
|
+
showProgress('Processing files', 0, 100);
|
|
75
|
+
for (let i = 0; i <= 100; i++) {
|
|
76
|
+
await processFile(i);
|
|
77
|
+
showProgress('Processing files', i, 100);
|
|
78
|
+
}
|
|
79
|
+
stopProgress();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Status Messages
|
|
83
|
+
|
|
84
|
+
Print colored status messages.
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { printSuccess, printError, printInfo, printWarning } from '@portel/cli';
|
|
88
|
+
|
|
89
|
+
printSuccess('Operation completed'); // ✓ green
|
|
90
|
+
printError('Something failed'); // ✗ red
|
|
91
|
+
printInfo('FYI...'); // ℹ blue
|
|
92
|
+
printWarning('Be careful'); // ⚠ yellow
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Fuzzy Matching
|
|
96
|
+
|
|
97
|
+
Find similar strings for "did you mean?" suggestions.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { FuzzyMatcher, findBestMatch } from '@portel/cli';
|
|
101
|
+
|
|
102
|
+
const matcher = new FuzzyMatcher();
|
|
103
|
+
const suggestions = matcher.findSuggestions('helo', ['hello', 'help', 'world']);
|
|
104
|
+
// => ['hello', 'help']
|
|
105
|
+
|
|
106
|
+
// Or simple best match
|
|
107
|
+
const best = findBestMatch('get-usrs', ['get-users', 'get-posts', 'delete-user']);
|
|
108
|
+
// => 'get-users'
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Text Utilities
|
|
112
|
+
|
|
113
|
+
Word wrapping, truncation, and formatting helpers.
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { TextUtils } from '@portel/cli';
|
|
117
|
+
|
|
118
|
+
TextUtils.wrap('Long text...', { width: 80 });
|
|
119
|
+
TextUtils.truncate('Very long string', 20);
|
|
120
|
+
TextUtils.padRight('Name', 10);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Logging
|
|
124
|
+
|
|
125
|
+
Structured logging with levels and formatting.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { createLogger } from '@portel/cli';
|
|
129
|
+
|
|
130
|
+
const logger = createLogger({ level: 'debug' });
|
|
131
|
+
logger.debug('Detailed info');
|
|
132
|
+
logger.info('General info');
|
|
133
|
+
logger.warn('Warning');
|
|
134
|
+
logger.error('Error occurred');
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## API Reference
|
|
138
|
+
|
|
139
|
+
### Formatting Functions
|
|
140
|
+
|
|
141
|
+
| Function | Description |
|
|
142
|
+
|----------|-------------|
|
|
143
|
+
| `formatOutput(data, hint?)` | Auto-format and print data |
|
|
144
|
+
| `detectFormat(data)` | Detect best format for data |
|
|
145
|
+
| `renderTable(data)` | Render bordered table |
|
|
146
|
+
| `renderTree(data)` | Render indented tree |
|
|
147
|
+
| `renderList(items)` | Render bullet list |
|
|
148
|
+
| `renderCard(data)` | Render key-value card |
|
|
149
|
+
|
|
150
|
+
### Progress Functions
|
|
151
|
+
|
|
152
|
+
| Function | Description |
|
|
153
|
+
|----------|-------------|
|
|
154
|
+
| `startSpinner(message)` | Start a spinner |
|
|
155
|
+
| `showProgress(label, current, total)` | Show progress bar |
|
|
156
|
+
| `updateProgressMessage(message)` | Update spinner text |
|
|
157
|
+
| `stopProgress()` | Stop spinner/progress |
|
|
158
|
+
| `isProgressActive()` | Check if progress is active |
|
|
159
|
+
|
|
160
|
+
### Status Functions
|
|
161
|
+
|
|
162
|
+
| Function | Description |
|
|
163
|
+
|----------|-------------|
|
|
164
|
+
| `printSuccess(message)` | Print success (green ✓) |
|
|
165
|
+
| `printError(message)` | Print error (red ✗) |
|
|
166
|
+
| `printInfo(message)` | Print info (blue ℹ) |
|
|
167
|
+
| `printWarning(message)` | Print warning (yellow ⚠) |
|
|
168
|
+
| `printHeader(text)` | Print section header |
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT
|