rbzk 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05c19d8aa64a72f6ca80b430058d5956f2c8250a59c60fb26548c9f546d62c3f
4
- data.tar.gz: 3ddd33169741c8f2df4046e9add74e21b4f8e4faccc8b5beb25994ac4b546cdc
3
+ metadata.gz: 683a39e67965c9497615c0371514fe71ce8a047cf0b083b1ae464f4320d3bd0f
4
+ data.tar.gz: b640310d6e167e6d4c07027298769bd4d1038ba71584f6860d79091189791f85
5
5
  SHA512:
6
- metadata.gz: 296b1eba45da43e51ef8e228fec546ad6b14894f1279219e66ff8f546469bb81e3a848f857d30b352a6a9db201762eee41a438ff606d041fe2e574e254840eab
7
- data.tar.gz: 6132ea677b868d354db28fc26e32087b933234985a7aaccfc029da1f220bd1655865350b086ef1cc8756f6f190ba41162ef5deaa36f8aa55c8f947d1076b9d38
6
+ metadata.gz: 2002e3c54b5626142cabdf2433baacdc8d116f79ac3831afe20b88b5c5a287019c20cf5c6e494170975affb7476e32b8986123826894beffb2a2a1dff0c5ad43
7
+ data.tar.gz: 4f27bac72f9241163ae046b36082ff76be75078d8e6a51ea91001cea141d6355e5af821c6b4d54d62a28db7ec11f382477663ee1f34883f1ea569b506435863b
data/README.md CHANGED
@@ -191,9 +191,168 @@ ensure
191
191
  end
192
192
  ```
193
193
 
194
- ### Complete Example
194
+ ## Command Line Interface
195
195
 
196
- See the `examples/complete_example.rb` file for a comprehensive example that demonstrates all the main functionality of the gem.
196
+ RBZK provides a powerful command-line interface for interacting with ZKTeco devices. The CLI is built using Thor, which provides a clean, intuitive interface similar to Git and other modern command-line tools.
197
+
198
+ ### Installation
199
+
200
+ After installing the gem, you can use the `rbzk` command directly:
201
+
202
+ ```bash
203
+ # Install the gem
204
+ gem install rbzk
205
+
206
+ # Use the command
207
+ bin/rbzk info 192.168.100.201
208
+ ```
209
+
210
+ If you're using Bundler, you can run the command through `bundle exec`:
211
+
212
+ ```bash
213
+ bundle exec rbzk info 192.168.100.201
214
+ ```
215
+
216
+ ### Available Commands
217
+
218
+ ```bash
219
+ # Get help
220
+ bin/rbzk help
221
+
222
+ # Get help for a specific command
223
+ bin/rbzk help logs
224
+ ```
225
+
226
+ #### Device Information
227
+
228
+ ```bash
229
+ # Get device information
230
+ bin/rbzk info 192.168.100.201 [options]
231
+ ```
232
+
233
+ #### Users
234
+
235
+ ```bash
236
+ # Get users from the device
237
+ bin/rbzk users 192.168.100.201 [options]
238
+ ```
239
+
240
+ #### Attendance Logs
241
+
242
+ ```bash
243
+ # Get all attendance logs
244
+ bin/rbzk logs 192.168.100.201 [options]
245
+
246
+ # Get today's logs
247
+ bin/rbzk logs 192.168.100.201 --today [options]
248
+
249
+ # Get yesterday's logs
250
+ bin/rbzk logs 192.168.100.201 --yesterday [options]
251
+
252
+ # Get this week's logs
253
+ bin/rbzk logs 192.168.100.201 --week [options]
254
+
255
+ # Get this month's logs
256
+ bin/rbzk logs 192.168.100.201 --month [options]
257
+
258
+ # Get logs for a custom date range
259
+ bin/rbzk logs 192.168.100.201 --start-date=2023-01-01 --end-date=2023-01-31 [options]
260
+ ```
261
+
262
+ #### Clear Logs
263
+
264
+ ```bash
265
+ # Clear attendance logs (will prompt for confirmation)
266
+ bin/rbzk clear_logs 192.168.100.201 [options]
267
+ ```
268
+
269
+ #### Test Voice
270
+
271
+ ```bash
272
+ # Test the device voice
273
+ bin/rbzk test_voice 192.168.100.201 [options]
274
+ ```
275
+
276
+ ### Global Options
277
+
278
+ These options can be used with any command:
279
+
280
+ ```
281
+ --ip=IP # Device IP address (default: from config or 192.168.100.201)
282
+ --port=PORT # Device port (default: from config or 4370)
283
+ --timeout=SECONDS # Connection timeout in seconds (default: from config or 30)
284
+ --password=PASSWORD # Device password (default: from config or 0)
285
+ --verbose # Enable verbose output (default: from config or false)
286
+ --force-udp # Use UDP instead of TCP (default: from config or false)
287
+ --no-ping # Skip ping check (default: from config or true)
288
+ --encoding=ENCODING # Character encoding (default: from config or UTF-8)
289
+ ```
290
+
291
+ ### Configuration
292
+
293
+ RBZK supports persistent configuration through a configuration file. This allows you to set default values for IP address and other options without having to specify them every time.
294
+
295
+ #### Configuration File Location
296
+
297
+ The configuration file is stored in one of the following locations (in order of precedence):
298
+
299
+ 1. `$XDG_CONFIG_HOME/rbzk/config.yml` (if `$XDG_CONFIG_HOME` is set)
300
+ 2. `$HOME/.config/rbzk/config.yml` (on most systems)
301
+ 3. `.rbzk.yml` in the current directory (fallback)
302
+
303
+ #### Configuration Commands
304
+
305
+ ```bash
306
+ # Show current configuration
307
+ bin/rbzk config
308
+
309
+ # Set a configuration value
310
+ bin/rbzk config-set ip 192.168.1.201
311
+ bin/rbzk config-set port 4371
312
+ bin/rbzk config-set password 12345
313
+ bin/rbzk config-set verbose true
314
+
315
+ # Reset configuration to defaults
316
+ bin/rbzk config-reset
317
+ ```
318
+
319
+ When you run commands, the CLI will use values from the configuration file as defaults. Command-line options will override the configuration file values.
320
+
321
+ ### Examples
322
+
323
+ ```bash
324
+ # Get device information
325
+ bin/rbzk info 192.168.100.201
326
+
327
+ # Get users with custom port and password
328
+ bin/rbzk users 192.168.100.201 --port=4371 --password=12345
329
+
330
+ # Get today's attendance logs with verbose output
331
+ bin/rbzk logs 192.168.100.201 --today --verbose
332
+
333
+ # Get logs for a custom date range (two ways)
334
+ bin/rbzk logs-custom 2023-01-01 2023-01-31 192.168.100.201
335
+ bin/rbzk logs 192.168.100.201 --start-date=2023-01-01 --end-date=2023-01-31
336
+
337
+ # Get logs from a specific date to today
338
+ bin/rbzk logs 192.168.100.201 --start-date=2023-01-01
339
+
340
+ # Get logs from 30 days before to a specific date
341
+ bin/rbzk logs 192.168.100.201 --end-date=2023-01-31
342
+
343
+ # Test voice with UDP connection
344
+ bin/rbzk test_voice 192.168.100.201 --force-udp
345
+ ```
346
+
347
+ ### Pretty Output
348
+
349
+ The command line interface uses the `terminal-table` gem for prettier output if it's available. To enable this feature, install the gem:
350
+
351
+ ```bash
352
+ gem install terminal-table
353
+ ```
354
+
355
+ If the gem is not available, the CLI will fall back to plain text output.
197
356
 
198
357
  ## Development
199
358
 
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rbzk"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/rbzk ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
5
+
6
+ require 'rbzk/cli/commands'
7
+
8
+ RBZK::CLI::Commands.start(ARGV)
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install