notifer-cli 1.0.0__tar.gz
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.
- notifer_cli-1.0.0/LICENSE +21 -0
- notifer_cli-1.0.0/PKG-INFO +325 -0
- notifer_cli-1.0.0/README.md +293 -0
- notifer_cli-1.0.0/notifer_cli/__init__.py +3 -0
- notifer_cli-1.0.0/notifer_cli/cli.py +47 -0
- notifer_cli-1.0.0/notifer_cli/client.py +198 -0
- notifer_cli-1.0.0/notifer_cli/commands/__init__.py +1 -0
- notifer_cli-1.0.0/notifer_cli/commands/auth.py +91 -0
- notifer_cli-1.0.0/notifer_cli/commands/config.py +142 -0
- notifer_cli-1.0.0/notifer_cli/commands/keys.py +187 -0
- notifer_cli-1.0.0/notifer_cli/commands/publish.py +75 -0
- notifer_cli-1.0.0/notifer_cli/commands/subscribe.py +129 -0
- notifer_cli-1.0.0/notifer_cli/commands/topics.py +197 -0
- notifer_cli-1.0.0/notifer_cli/config.py +76 -0
- notifer_cli-1.0.0/notifer_cli.egg-info/PKG-INFO +325 -0
- notifer_cli-1.0.0/notifer_cli.egg-info/SOURCES.txt +20 -0
- notifer_cli-1.0.0/notifer_cli.egg-info/dependency_links.txt +1 -0
- notifer_cli-1.0.0/notifer_cli.egg-info/entry_points.txt +2 -0
- notifer_cli-1.0.0/notifer_cli.egg-info/requires.txt +5 -0
- notifer_cli-1.0.0/notifer_cli.egg-info/top_level.txt +1 -0
- notifer_cli-1.0.0/pyproject.toml +48 -0
- notifer_cli-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nexolab Projects
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: notifer-cli
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Command-line interface for Notifer notification service
|
|
5
|
+
Author-email: Notifer Team <hello@notifer.io>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://notifer.io
|
|
8
|
+
Project-URL: Documentation, https://docs.notifer.io
|
|
9
|
+
Project-URL: Repository, https://github.com/nexolab-projects/notifer-cli
|
|
10
|
+
Project-URL: Issues, https://github.com/nexolab-projects/notifer-cli/issues
|
|
11
|
+
Keywords: notifications,cli,pub-sub,push-notifications
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Topic :: Communications
|
|
16
|
+
Classifier: Topic :: Utilities
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: click>=8.1.0
|
|
27
|
+
Requires-Dist: requests>=2.31.0
|
|
28
|
+
Requires-Dist: pyyaml>=6.0
|
|
29
|
+
Requires-Dist: rich>=13.0.0
|
|
30
|
+
Requires-Dist: sseclient-py>=1.8.0
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# Notifer CLI
|
|
34
|
+
|
|
35
|
+
Command-line interface for [Notifer](https://notifer.io) - simple HTTP-based pub-sub notification service.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install notifer-cli
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or install from source:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://github.com/notifer/notifer.git
|
|
47
|
+
cd notifer/cli
|
|
48
|
+
pip install -e .
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### 1. Configure API endpoint
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Create config file
|
|
57
|
+
notifer config init
|
|
58
|
+
|
|
59
|
+
# For production (Notifer cloud)
|
|
60
|
+
notifer config set server https://api.notifer.io
|
|
61
|
+
|
|
62
|
+
# For local development
|
|
63
|
+
notifer config set server http://localhost:8080
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Publish a message
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Simple message
|
|
70
|
+
notifer publish my-topic "Hello World!"
|
|
71
|
+
|
|
72
|
+
# With title and priority
|
|
73
|
+
notifer publish alerts "Server is down!" \
|
|
74
|
+
--title "Alert" \
|
|
75
|
+
--priority 5 \
|
|
76
|
+
--tags urgent,server
|
|
77
|
+
|
|
78
|
+
# With markdown
|
|
79
|
+
notifer publish deployments "# Deploy Success\n\n**Status**: ✅" \
|
|
80
|
+
--priority 4
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 3. Subscribe to messages
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Subscribe and print to console
|
|
87
|
+
notifer subscribe my-topic
|
|
88
|
+
|
|
89
|
+
# Subscribe to multiple topics
|
|
90
|
+
notifer subscribe alerts,deployments
|
|
91
|
+
|
|
92
|
+
# Save to file
|
|
93
|
+
notifer subscribe my-topic --output messages.jsonl
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Authentication
|
|
97
|
+
|
|
98
|
+
### Using API Keys (Recommended)
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Create API key via web UI or:
|
|
102
|
+
notifer keys create "CI/CD Pipeline" \
|
|
103
|
+
--scopes publish,topics:read \
|
|
104
|
+
--email user@example.com \
|
|
105
|
+
--password yourpassword
|
|
106
|
+
|
|
107
|
+
# Use API key for publishing
|
|
108
|
+
notifer publish my-topic "Message" --api-key noti_abc123...
|
|
109
|
+
|
|
110
|
+
# Or save in config
|
|
111
|
+
notifer config set api-key noti_abc123...
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Using Email/Password
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Login (stores token in ~/.notifer.yaml)
|
|
118
|
+
notifer login user@example.com
|
|
119
|
+
|
|
120
|
+
# Publish with stored credentials
|
|
121
|
+
notifer publish my-topic "Message"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Commands
|
|
125
|
+
|
|
126
|
+
### Publishing
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
notifer publish <topic> <message> [OPTIONS]
|
|
130
|
+
|
|
131
|
+
Options:
|
|
132
|
+
--title TEXT Message title
|
|
133
|
+
--priority INTEGER Priority (1-5, default: 3)
|
|
134
|
+
--tags TEXT Comma-separated tags
|
|
135
|
+
--api-key TEXT API key for authentication
|
|
136
|
+
--server TEXT Override server URL
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Subscribing
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
notifer subscribe <topics> [OPTIONS]
|
|
143
|
+
|
|
144
|
+
Options:
|
|
145
|
+
--output PATH Save messages to file (JSONL format)
|
|
146
|
+
--since TEXT Only show messages since timestamp
|
|
147
|
+
--api-key TEXT API key for authentication
|
|
148
|
+
--json Output raw JSON (no formatting)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### API Keys Management
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# List API keys
|
|
155
|
+
notifer keys list
|
|
156
|
+
|
|
157
|
+
# Create new key
|
|
158
|
+
notifer keys create <name> [OPTIONS]
|
|
159
|
+
|
|
160
|
+
Options:
|
|
161
|
+
--scopes TEXT Comma-separated scopes (default: *)
|
|
162
|
+
--description TEXT Key description
|
|
163
|
+
--expires TEXT Expiration date (ISO format)
|
|
164
|
+
|
|
165
|
+
# Revoke key
|
|
166
|
+
notifer keys revoke <key-id>
|
|
167
|
+
|
|
168
|
+
# Delete key
|
|
169
|
+
notifer keys delete <key-id>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Topics Management
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# List topics
|
|
176
|
+
notifer topics list
|
|
177
|
+
|
|
178
|
+
# List your topics
|
|
179
|
+
notifer topics list --mine
|
|
180
|
+
|
|
181
|
+
# Create topic
|
|
182
|
+
notifer topics create <name> [OPTIONS]
|
|
183
|
+
|
|
184
|
+
Options:
|
|
185
|
+
--description TEXT Topic description
|
|
186
|
+
--private Make topic private
|
|
187
|
+
--discoverable Make discoverable in browse
|
|
188
|
+
|
|
189
|
+
# Get topic info
|
|
190
|
+
notifer topics get <name>
|
|
191
|
+
|
|
192
|
+
# Delete topic
|
|
193
|
+
notifer topics delete <name>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Configuration
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Initialize config file
|
|
200
|
+
notifer config init
|
|
201
|
+
|
|
202
|
+
# Show current config
|
|
203
|
+
notifer config show
|
|
204
|
+
|
|
205
|
+
# Set config value
|
|
206
|
+
notifer config set <key> <value>
|
|
207
|
+
|
|
208
|
+
# Examples:
|
|
209
|
+
notifer config set server https://api.notifer.io # Production
|
|
210
|
+
notifer config set server http://localhost:8080 # Local dev
|
|
211
|
+
notifer config set api-key noti_abc123...
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Configuration File
|
|
215
|
+
|
|
216
|
+
The CLI uses `~/.notifer.yaml` for configuration:
|
|
217
|
+
|
|
218
|
+
```yaml
|
|
219
|
+
# Server settings
|
|
220
|
+
server: https://api.notifer.io # Production (or http://localhost:8080 for local dev)
|
|
221
|
+
|
|
222
|
+
# Authentication (choose one)
|
|
223
|
+
api_key: noti_abc123...
|
|
224
|
+
|
|
225
|
+
# OR email/password (stores JWT token)
|
|
226
|
+
email: user@example.com
|
|
227
|
+
access_token: eyJhbG...
|
|
228
|
+
refresh_token: eyJhbG...
|
|
229
|
+
|
|
230
|
+
# Default options
|
|
231
|
+
defaults:
|
|
232
|
+
priority: 3
|
|
233
|
+
tags: []
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Examples
|
|
237
|
+
|
|
238
|
+
### CI/CD Integration
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
#!/bin/bash
|
|
242
|
+
# deploy.sh
|
|
243
|
+
|
|
244
|
+
# Create API key with publish scope
|
|
245
|
+
API_KEY="noti_abc123..."
|
|
246
|
+
|
|
247
|
+
# Notify on deploy start
|
|
248
|
+
notifer publish deployments "Deploy started for v1.2.3" \
|
|
249
|
+
--title "Deploy" \
|
|
250
|
+
--priority 3 \
|
|
251
|
+
--tags deployment,production \
|
|
252
|
+
--api-key "$API_KEY"
|
|
253
|
+
|
|
254
|
+
# Run deployment
|
|
255
|
+
./deploy-script.sh
|
|
256
|
+
|
|
257
|
+
# Notify on success/failure
|
|
258
|
+
if [ $? -eq 0 ]; then
|
|
259
|
+
notifer publish deployments "# Deploy Success\n\nVersion **v1.2.3** deployed!" \
|
|
260
|
+
--priority 4 \
|
|
261
|
+
--tags deployment,success \
|
|
262
|
+
--api-key "$API_KEY"
|
|
263
|
+
else
|
|
264
|
+
notifer publish deployments "Deploy failed!" \
|
|
265
|
+
--priority 5 \
|
|
266
|
+
--tags deployment,failure \
|
|
267
|
+
--api-key "$API_KEY"
|
|
268
|
+
fi
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Monitoring Script
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
#!/bin/bash
|
|
275
|
+
# monitor.sh
|
|
276
|
+
|
|
277
|
+
# Subscribe to alerts and log to file
|
|
278
|
+
notifer subscribe alerts,errors \
|
|
279
|
+
--output /var/log/notifer-alerts.jsonl \
|
|
280
|
+
--api-key noti_abc123...
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### GitHub Actions
|
|
284
|
+
|
|
285
|
+
```yaml
|
|
286
|
+
name: Deploy
|
|
287
|
+
on:
|
|
288
|
+
push:
|
|
289
|
+
branches: [main]
|
|
290
|
+
|
|
291
|
+
jobs:
|
|
292
|
+
deploy:
|
|
293
|
+
runs-on: ubuntu-latest
|
|
294
|
+
steps:
|
|
295
|
+
- uses: actions/checkout@v3
|
|
296
|
+
|
|
297
|
+
- name: Install Notifer CLI
|
|
298
|
+
run: pip install notifer-cli
|
|
299
|
+
|
|
300
|
+
- name: Notify deploy start
|
|
301
|
+
run: |
|
|
302
|
+
notifer publish deployments "Deploy started: ${{ github.sha }}" \
|
|
303
|
+
--api-key ${{ secrets.NOTIFER_API_KEY }}
|
|
304
|
+
|
|
305
|
+
- name: Deploy
|
|
306
|
+
run: ./deploy.sh
|
|
307
|
+
|
|
308
|
+
- name: Notify success
|
|
309
|
+
if: success()
|
|
310
|
+
run: |
|
|
311
|
+
notifer publish deployments "Deploy successful!" \
|
|
312
|
+
--priority 4 \
|
|
313
|
+
--api-key ${{ secrets.NOTIFER_API_KEY }}
|
|
314
|
+
|
|
315
|
+
- name: Notify failure
|
|
316
|
+
if: failure()
|
|
317
|
+
run: |
|
|
318
|
+
notifer publish deployments "Deploy failed!" \
|
|
319
|
+
--priority 5 \
|
|
320
|
+
--api-key ${{ secrets.NOTIFER_API_KEY }}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## License
|
|
324
|
+
|
|
325
|
+
MIT
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# Notifer CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for [Notifer](https://notifer.io) - simple HTTP-based pub-sub notification service.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install notifer-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or install from source:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
git clone https://github.com/notifer/notifer.git
|
|
15
|
+
cd notifer/cli
|
|
16
|
+
pip install -e .
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### 1. Configure API endpoint
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Create config file
|
|
25
|
+
notifer config init
|
|
26
|
+
|
|
27
|
+
# For production (Notifer cloud)
|
|
28
|
+
notifer config set server https://api.notifer.io
|
|
29
|
+
|
|
30
|
+
# For local development
|
|
31
|
+
notifer config set server http://localhost:8080
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. Publish a message
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Simple message
|
|
38
|
+
notifer publish my-topic "Hello World!"
|
|
39
|
+
|
|
40
|
+
# With title and priority
|
|
41
|
+
notifer publish alerts "Server is down!" \
|
|
42
|
+
--title "Alert" \
|
|
43
|
+
--priority 5 \
|
|
44
|
+
--tags urgent,server
|
|
45
|
+
|
|
46
|
+
# With markdown
|
|
47
|
+
notifer publish deployments "# Deploy Success\n\n**Status**: ✅" \
|
|
48
|
+
--priority 4
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 3. Subscribe to messages
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Subscribe and print to console
|
|
55
|
+
notifer subscribe my-topic
|
|
56
|
+
|
|
57
|
+
# Subscribe to multiple topics
|
|
58
|
+
notifer subscribe alerts,deployments
|
|
59
|
+
|
|
60
|
+
# Save to file
|
|
61
|
+
notifer subscribe my-topic --output messages.jsonl
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Authentication
|
|
65
|
+
|
|
66
|
+
### Using API Keys (Recommended)
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Create API key via web UI or:
|
|
70
|
+
notifer keys create "CI/CD Pipeline" \
|
|
71
|
+
--scopes publish,topics:read \
|
|
72
|
+
--email user@example.com \
|
|
73
|
+
--password yourpassword
|
|
74
|
+
|
|
75
|
+
# Use API key for publishing
|
|
76
|
+
notifer publish my-topic "Message" --api-key noti_abc123...
|
|
77
|
+
|
|
78
|
+
# Or save in config
|
|
79
|
+
notifer config set api-key noti_abc123...
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Using Email/Password
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Login (stores token in ~/.notifer.yaml)
|
|
86
|
+
notifer login user@example.com
|
|
87
|
+
|
|
88
|
+
# Publish with stored credentials
|
|
89
|
+
notifer publish my-topic "Message"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Commands
|
|
93
|
+
|
|
94
|
+
### Publishing
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
notifer publish <topic> <message> [OPTIONS]
|
|
98
|
+
|
|
99
|
+
Options:
|
|
100
|
+
--title TEXT Message title
|
|
101
|
+
--priority INTEGER Priority (1-5, default: 3)
|
|
102
|
+
--tags TEXT Comma-separated tags
|
|
103
|
+
--api-key TEXT API key for authentication
|
|
104
|
+
--server TEXT Override server URL
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Subscribing
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
notifer subscribe <topics> [OPTIONS]
|
|
111
|
+
|
|
112
|
+
Options:
|
|
113
|
+
--output PATH Save messages to file (JSONL format)
|
|
114
|
+
--since TEXT Only show messages since timestamp
|
|
115
|
+
--api-key TEXT API key for authentication
|
|
116
|
+
--json Output raw JSON (no formatting)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### API Keys Management
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# List API keys
|
|
123
|
+
notifer keys list
|
|
124
|
+
|
|
125
|
+
# Create new key
|
|
126
|
+
notifer keys create <name> [OPTIONS]
|
|
127
|
+
|
|
128
|
+
Options:
|
|
129
|
+
--scopes TEXT Comma-separated scopes (default: *)
|
|
130
|
+
--description TEXT Key description
|
|
131
|
+
--expires TEXT Expiration date (ISO format)
|
|
132
|
+
|
|
133
|
+
# Revoke key
|
|
134
|
+
notifer keys revoke <key-id>
|
|
135
|
+
|
|
136
|
+
# Delete key
|
|
137
|
+
notifer keys delete <key-id>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Topics Management
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# List topics
|
|
144
|
+
notifer topics list
|
|
145
|
+
|
|
146
|
+
# List your topics
|
|
147
|
+
notifer topics list --mine
|
|
148
|
+
|
|
149
|
+
# Create topic
|
|
150
|
+
notifer topics create <name> [OPTIONS]
|
|
151
|
+
|
|
152
|
+
Options:
|
|
153
|
+
--description TEXT Topic description
|
|
154
|
+
--private Make topic private
|
|
155
|
+
--discoverable Make discoverable in browse
|
|
156
|
+
|
|
157
|
+
# Get topic info
|
|
158
|
+
notifer topics get <name>
|
|
159
|
+
|
|
160
|
+
# Delete topic
|
|
161
|
+
notifer topics delete <name>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Configuration
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Initialize config file
|
|
168
|
+
notifer config init
|
|
169
|
+
|
|
170
|
+
# Show current config
|
|
171
|
+
notifer config show
|
|
172
|
+
|
|
173
|
+
# Set config value
|
|
174
|
+
notifer config set <key> <value>
|
|
175
|
+
|
|
176
|
+
# Examples:
|
|
177
|
+
notifer config set server https://api.notifer.io # Production
|
|
178
|
+
notifer config set server http://localhost:8080 # Local dev
|
|
179
|
+
notifer config set api-key noti_abc123...
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Configuration File
|
|
183
|
+
|
|
184
|
+
The CLI uses `~/.notifer.yaml` for configuration:
|
|
185
|
+
|
|
186
|
+
```yaml
|
|
187
|
+
# Server settings
|
|
188
|
+
server: https://api.notifer.io # Production (or http://localhost:8080 for local dev)
|
|
189
|
+
|
|
190
|
+
# Authentication (choose one)
|
|
191
|
+
api_key: noti_abc123...
|
|
192
|
+
|
|
193
|
+
# OR email/password (stores JWT token)
|
|
194
|
+
email: user@example.com
|
|
195
|
+
access_token: eyJhbG...
|
|
196
|
+
refresh_token: eyJhbG...
|
|
197
|
+
|
|
198
|
+
# Default options
|
|
199
|
+
defaults:
|
|
200
|
+
priority: 3
|
|
201
|
+
tags: []
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Examples
|
|
205
|
+
|
|
206
|
+
### CI/CD Integration
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
#!/bin/bash
|
|
210
|
+
# deploy.sh
|
|
211
|
+
|
|
212
|
+
# Create API key with publish scope
|
|
213
|
+
API_KEY="noti_abc123..."
|
|
214
|
+
|
|
215
|
+
# Notify on deploy start
|
|
216
|
+
notifer publish deployments "Deploy started for v1.2.3" \
|
|
217
|
+
--title "Deploy" \
|
|
218
|
+
--priority 3 \
|
|
219
|
+
--tags deployment,production \
|
|
220
|
+
--api-key "$API_KEY"
|
|
221
|
+
|
|
222
|
+
# Run deployment
|
|
223
|
+
./deploy-script.sh
|
|
224
|
+
|
|
225
|
+
# Notify on success/failure
|
|
226
|
+
if [ $? -eq 0 ]; then
|
|
227
|
+
notifer publish deployments "# Deploy Success\n\nVersion **v1.2.3** deployed!" \
|
|
228
|
+
--priority 4 \
|
|
229
|
+
--tags deployment,success \
|
|
230
|
+
--api-key "$API_KEY"
|
|
231
|
+
else
|
|
232
|
+
notifer publish deployments "Deploy failed!" \
|
|
233
|
+
--priority 5 \
|
|
234
|
+
--tags deployment,failure \
|
|
235
|
+
--api-key "$API_KEY"
|
|
236
|
+
fi
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Monitoring Script
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
#!/bin/bash
|
|
243
|
+
# monitor.sh
|
|
244
|
+
|
|
245
|
+
# Subscribe to alerts and log to file
|
|
246
|
+
notifer subscribe alerts,errors \
|
|
247
|
+
--output /var/log/notifer-alerts.jsonl \
|
|
248
|
+
--api-key noti_abc123...
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### GitHub Actions
|
|
252
|
+
|
|
253
|
+
```yaml
|
|
254
|
+
name: Deploy
|
|
255
|
+
on:
|
|
256
|
+
push:
|
|
257
|
+
branches: [main]
|
|
258
|
+
|
|
259
|
+
jobs:
|
|
260
|
+
deploy:
|
|
261
|
+
runs-on: ubuntu-latest
|
|
262
|
+
steps:
|
|
263
|
+
- uses: actions/checkout@v3
|
|
264
|
+
|
|
265
|
+
- name: Install Notifer CLI
|
|
266
|
+
run: pip install notifer-cli
|
|
267
|
+
|
|
268
|
+
- name: Notify deploy start
|
|
269
|
+
run: |
|
|
270
|
+
notifer publish deployments "Deploy started: ${{ github.sha }}" \
|
|
271
|
+
--api-key ${{ secrets.NOTIFER_API_KEY }}
|
|
272
|
+
|
|
273
|
+
- name: Deploy
|
|
274
|
+
run: ./deploy.sh
|
|
275
|
+
|
|
276
|
+
- name: Notify success
|
|
277
|
+
if: success()
|
|
278
|
+
run: |
|
|
279
|
+
notifer publish deployments "Deploy successful!" \
|
|
280
|
+
--priority 4 \
|
|
281
|
+
--api-key ${{ secrets.NOTIFER_API_KEY }}
|
|
282
|
+
|
|
283
|
+
- name: Notify failure
|
|
284
|
+
if: failure()
|
|
285
|
+
run: |
|
|
286
|
+
notifer publish deployments "Deploy failed!" \
|
|
287
|
+
--priority 5 \
|
|
288
|
+
--api-key ${{ secrets.NOTIFER_API_KEY }}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## License
|
|
292
|
+
|
|
293
|
+
MIT
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Main CLI entry point."""
|
|
2
|
+
import click
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
|
|
5
|
+
from .commands import publish, subscribe, keys, topics, config, auth
|
|
6
|
+
|
|
7
|
+
console = Console()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@click.group()
|
|
11
|
+
@click.version_option(version="1.0.0", prog_name="notifer")
|
|
12
|
+
@click.pass_context
|
|
13
|
+
def cli(ctx):
|
|
14
|
+
"""
|
|
15
|
+
Notifer CLI - Simple pub-sub notifications from the command line.
|
|
16
|
+
|
|
17
|
+
Send and receive notifications, manage API keys, and configure topics.
|
|
18
|
+
|
|
19
|
+
\b
|
|
20
|
+
Examples:
|
|
21
|
+
# Publish a message
|
|
22
|
+
notifer publish my-topic "Hello World!"
|
|
23
|
+
|
|
24
|
+
# Subscribe to messages
|
|
25
|
+
notifer subscribe my-topic
|
|
26
|
+
|
|
27
|
+
# Manage API keys
|
|
28
|
+
notifer keys create "CI/CD" --scopes publish
|
|
29
|
+
|
|
30
|
+
For more help on a specific command:
|
|
31
|
+
notifer <command> --help
|
|
32
|
+
"""
|
|
33
|
+
ctx.ensure_object(dict)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# Register command groups
|
|
37
|
+
cli.add_command(publish.publish)
|
|
38
|
+
cli.add_command(subscribe.subscribe)
|
|
39
|
+
cli.add_command(keys.keys)
|
|
40
|
+
cli.add_command(topics.topics)
|
|
41
|
+
cli.add_command(config.config)
|
|
42
|
+
cli.add_command(auth.login)
|
|
43
|
+
cli.add_command(auth.logout)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
cli()
|