diff --git a/Makefile b/Makefile index 3b03a2f..5ff6dc9 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,15 @@ bindir = $(prefix)/bin INSTALL = install INSTALL_PROGRAM = $(INSTALL) -m 755 -build: blueutil +build: blueutil update_usage format: clang-format -i *.m +update_usage: blueutil + ./update_usage + touch update_usage + test: build ./test diff --git a/README.md b/README.md index 3738c3b..656bd64 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ CLI for bluetooth on OSX: power, discoverable state, list, inquire devices, conn ## Usage + ``` Usage: blueutil [options] @@ -18,27 +19,40 @@ Without options outputs current state --favourites list favourite devices --inquiry [T] inquiry devices in range, 10 seconds duration by default excluding time for name updates --paired list paired devices - --recent [N] list recently used devices, 10 by default + --recent [N] list recently used devices, 10 by default, 0 to list all --info ID show information about device --is-connected ID connected state of device as 1 or 0 --connect ID create a connection to device --disconnect ID close the connection to device --pair ID [PIN] pair with device, optional PIN of up to 16 characters will be used instead of interactive input if requested in specific pair mode + --add-favourite ID add to favourites + --remove-favourite ID remove from favourites --format FORMAT change output format of info and all listing commands + --wait-connect ID [TIMEOUT] + EXPERIMENTAL wait for device to connect + --wait-disconnect ID [TIMEOUT] + EXPERIMENTAL wait for device to disconnect + --wait-rssi ID OP VALUE [PERIOD [TIMEOUT]] + EXPERIMENTAL wait for device RSSI value which is 0 for golden range, -129 if it cannot be read (e.g. device is disconnected) + -h, --help this help -v, --version show version STATE can be one of: 1, on, 0, off, toggle ID can be either address in form xxxxxxxxxxxx, xx-xx-xx-xx-xx-xx or xx:xx:xx:xx:xx:xx, or name of device to search in used devices +OP can be one of: >, >=, <, <=, =, !=; or equivalents: gt, ge, lt, le, eq, ne +PERIOD is in seconds, defaults to 1 +TIMEOUT is in seconds, default value 0 doesn't add timeout FORMAT can be one of: default - human readable text output not intended for consumption by scripts new-default - human readable comma separated key-value pairs (EXPERIMENTAL, THE BEHAVIOUR MAY CHANGE) json - compact JSON json-pretty - pretty printed JSON ``` + ## Install/update/uninstall diff --git a/update_usage b/update_usage new file mode 100755 index 0000000..75597bf --- /dev/null +++ b/update_usage @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +require 'pathname' + +USAGE_REGEXP = / + (?#{Regexp.escape ''}) + .* + (?#{Regexp.escape ''}) +/mx + +path = Pathname('README.md') + +original = path.read +changed = original.sub(USAGE_REGEXP) do + m = Regexp.last_match + system 'make -s blueutil' + usage = `./blueutil --help`.sub(/\Ablueutil v.*/, '').lstrip + "#{m[:open]}\n```\n#{usage}```\n#{m[:close]}" +end + +path.open('w'){ |f| f.write(changed) } unless original == changed