1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
//! # Cargo Hammerwork CLI
//!
//! A comprehensive command-line interface for managing Hammerwork job queues.
//!
//! This crate provides the `cargo hammerwork` CLI tool for database migrations,
//! job management, worker control, queue operations, and monitoring of Hammerwork
//! job processing systems.
//!
//! ## Installation
//!
//! ```bash
//! cargo install cargo-hammerwork --features postgres
//! # or
//! cargo install cargo-hammerwork --features mysql
//! ```
//!
//! ## Basic Usage
//!
//! The CLI can be invoked either as a cargo subcommand or directly:
//!
//! ```bash
//! # As cargo subcommand
//! cargo hammerwork migration status --database-url postgresql://localhost/mydb
//!
//! # Direct invocation
//! cargo-hammerwork migration status --database-url postgresql://localhost/mydb
//! ```
//!
//! ## Common Commands
//!
//! ### Database Migrations
//!
//! ```bash
//! # Run all pending migrations
//! cargo hammerwork migration run --database-url postgresql://localhost/mydb
//!
//! # Check migration status
//! cargo hammerwork migration status --database-url postgresql://localhost/mydb
//!
//! # Rollback last migration
//! cargo hammerwork migration rollback --database-url postgresql://localhost/mydb
//! ```
//!
//! ### Job Management
//!
//! ```bash
//! # List jobs in a queue
//! cargo hammerwork job list --database-url postgresql://localhost/mydb --queue default
//!
//! # Enqueue a new job
//! cargo hammerwork job enqueue --database-url postgresql://localhost/mydb \
//! --queue email --payload '{"to": "user@example.com"}'
//!
//! # Retry failed jobs
//! cargo hammerwork job retry --database-url postgresql://localhost/mydb --all-failed
//!
//! # Cancel a specific job
//! cargo hammerwork job cancel --database-url postgresql://localhost/mydb <job-id>
//! ```
//!
//! ### Queue Operations
//!
//! ```bash
//! # List all queues with statistics
//! cargo hammerwork queue list --database-url postgresql://localhost/mydb
//!
//! # Clear dead jobs from a queue
//! cargo hammerwork queue clear --database-url postgresql://localhost/mydb \
//! --queue default --dead
//!
//! # Show queue statistics
//! cargo hammerwork queue stats --database-url postgresql://localhost/mydb \
//! --queue default
//! ```
//!
//! ### Worker Management
//!
//! ```bash
//! # Start a worker (requires configuration file)
//! cargo hammerwork worker start --database-url postgresql://localhost/mydb \
//! --queue default --handler ./my_handler
//!
//! # Show worker status
//! cargo hammerwork worker status --database-url postgresql://localhost/mydb
//!
//! # Stop all workers gracefully
//! cargo hammerwork worker stop --database-url postgresql://localhost/mydb --all
//! ```
//!
//! ### Monitoring
//!
//! ```bash
//! # Show real-time dashboard
//! cargo hammerwork monitor dashboard --database-url postgresql://localhost/mydb
//!
//! # Display queue metrics
//! cargo hammerwork monitor metrics --database-url postgresql://localhost/mydb
//!
//! # Check system health
//! cargo hammerwork monitor health --database-url postgresql://localhost/mydb
//! ```
//!
//! ## Configuration
//!
//! The CLI supports configuration files to avoid repetitive arguments:
//!
//! ```bash
//! # Create default config
//! cargo hammerwork config init
//!
//! # Show current config
//! cargo hammerwork config show
//!
//! # Set database URL in config
//! cargo hammerwork config set database_url postgresql://localhost/mydb
//! ```
//!
//! Configuration files are stored at:
//! - Linux/Mac: `~/.config/hammerwork/config.toml`
//! - Windows: `%APPDATA%\hammerwork\config.toml`
//!
//! ## Environment Variables
//!
//! The CLI respects these environment variables:
//!
//! - `DATABASE_URL` - Default database connection URL
//! - `HAMMERWORK_CONFIG` - Path to config file
//! - `HAMMERWORK_LOG` - Log level (error, warn, info, debug, trace)
//!
//! ## Examples
//!
//! ### Complete Workflow Example
//!
//! ```bash
//! # 1. Initialize configuration
//! cargo hammerwork config init
//! cargo hammerwork config set database_url postgresql://localhost/hammerwork
//!
//! # 2. Run migrations to set up database
//! cargo hammerwork migration run
//!
//! # 3. Enqueue some jobs
//! cargo hammerwork job enqueue --queue email \
//! --payload '{"to": "user@example.com", "subject": "Welcome!"}'
//!
//! cargo hammerwork job enqueue --queue email \
//! --payload '{"to": "admin@example.com", "subject": "New user"}' \
//! --priority high
//!
//! # 4. Check queue status
//! cargo hammerwork queue list
//!
//! # 5. Process jobs (in another terminal)
//! cargo hammerwork worker start --queue email
//!
//! # 6. Monitor progress
//! cargo hammerwork monitor dashboard
//! ```
//!
//! ### Batch Operations Example
//!
//! ```bash
//! # Enqueue multiple jobs at once
//! cargo hammerwork batch enqueue --queue data-processing \
//! --payloads '[
//! {"file": "data1.csv"},
//! {"file": "data2.csv"},
//! {"file": "data3.csv"}
//! ]'
//!
//! # Cancel all jobs in a batch
//! cargo hammerwork batch cancel <batch-id>
//!
//! # Show batch status
//! cargo hammerwork batch status <batch-id>
//! ```
//!
//! ### Cron Scheduling Example
//!
//! ```bash
//! # Create a recurring job
//! cargo hammerwork cron create --queue reports \
//! --schedule "0 9 * * MON-FRI" \
//! --timezone "America/New_York" \
//! --payload '{"type": "daily_report"}'
//!
//! # List cron jobs
//! cargo hammerwork cron list
//!
//! # Disable a cron job
//! cargo hammerwork cron disable <job-id>
//! ```
//!
//! ## Feature Flags
//!
//! - `postgres` - PostgreSQL support (recommended)
//! - `mysql` - MySQL support
//! - `completions` - Shell completion generation
//!
//! ## Error Handling
//!
//! The CLI provides detailed error messages and non-zero exit codes on failure:
//!
//! - Exit code 0: Success
//! - Exit code 1: General error
//! - Exit code 2: Configuration error
//! - Exit code 3: Database connection error
//! - Exit code 4: Invalid arguments
//!
//! ## Verbose and Quiet Modes
//!
//! Control output verbosity with global flags:
//!
//! ```bash
//! # Verbose mode - show debug information
//! cargo hammerwork -v migration run
//!
//! # Quiet mode - suppress all but errors
//! cargo hammerwork -q job list
//! ```
pub use *;
pub use *;
pub use *;