mac-wifi 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -39
- data/RELEASE_NOTES.md +18 -0
- data/exe/mac-wifi +284 -108
- data/mac-wifi.gemspec +1 -1
- data/sample-avail-network-data.xml +4042 -0
- data/sample-available-networks.json +27 -0
- data/sample-available-networks.yaml +26 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bce9a95ee880536f6e3672191ed7d343b1eafcf
|
4
|
+
data.tar.gz: 10aeeddeb2bc4bf946a65d9709b2306ea8567ed9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04224a7842e14437d0de854e6bc9566901893c547b73e4ca581b159d92816bf789d3235919b8593fdf74b32e9cfebfe7c14f7974498a268117eafeb37a0eb785
|
7
|
+
data.tar.gz: 5b8db8d42cb1b0284dc61d0557030ffa49f2bc3987f8272ccef93fa23d40be2553346635a9f996941a7fa2f2f19f351687c0fb2855203f6f2c8da5a5493c07b3
|
data/README.md
CHANGED
@@ -4,11 +4,16 @@ The `mac-wifi` script installed by this gem (or otherwise copied) enables the qu
|
|
4
4
|
The code encapsulates the Mac OS specific logic in a minimal class to more easily add support for other operating systems,
|
5
5
|
but as of now, only Mac OS is supported. (Feel free to add an OS!)
|
6
6
|
|
7
|
-
It can be run in single-command or interactive mode. Interactive mode uses the
|
7
|
+
It can be run in single-command or interactive mode. Interactive mode uses the [pry](https://github.com/pry/pry) gem,
|
8
8
|
providing an interface familiar to Rubyists and other
|
9
9
|
[REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) users.
|
10
10
|
|
11
|
-
It is not necessary to download this repo or even install this gem; the `bin/mac-wifi`
|
11
|
+
It is not necessary to download this repo or even install this gem; the `bin/mac-wifi`
|
12
|
+
script file is all you need to run the application. There are many ways to install it
|
13
|
+
in this way; one way is by changing into the directory
|
14
|
+
where you would like to save the script, and running:
|
15
|
+
|
16
|
+
`curl -o mac-wifi https://raw.githubusercontent.com/keithrbennett/macwifi/master/exe/mac-wifi && chmod +x mac-wifi`
|
12
17
|
|
13
18
|
|
14
19
|
### Usage
|
@@ -19,24 +24,29 @@ output at the time of this writing:
|
|
19
24
|
```
|
20
25
|
$ mac-wifi h
|
21
26
|
|
27
|
+
Command Line Switches: [mac-wifi version 2.0.0]
|
28
|
+
|
29
|
+
-o[i,j,p,y] - outputs data in inspect, JSON, puts, or YAML format when not in shell mode
|
30
|
+
-s - run in shell mode
|
31
|
+
-v - verbose mode (prints OS commands and their outputs)
|
22
32
|
|
23
|
-
|
33
|
+
Commands:
|
24
34
|
|
25
|
-
a[
|
35
|
+
a[vail_nets] - array of names of the available networks
|
26
36
|
ci - connected to Internet (not just wifi on)?
|
27
37
|
co[nnect] network-name - turns wifi on, connects to network-name
|
28
38
|
cy[cle] - turns wifi off, then on, preserving network selection
|
29
39
|
d[isconnect] - disconnects from current network, does not turn off wifi
|
30
40
|
h[elp] - prints this help
|
31
41
|
i[nfo] - a hash of wifi-related information
|
32
|
-
l[
|
42
|
+
l[s_avail_nets] - details about available networks
|
33
43
|
n[etwork_name] - name (SSID) of currently connected network
|
34
44
|
on - turns wifi on
|
35
45
|
of[f] - turns wifi off
|
36
46
|
pa[ssword] network-name - password for preferred network-name
|
37
|
-
pr[
|
47
|
+
pr[ef_nets] - preferred (not necessarily available) networks
|
38
48
|
q[uit] - exits this program (interactive shell mode only) (see also 'x')
|
39
|
-
r[
|
49
|
+
r[m_pref_nets] network-name - removes network-name from the preferred networks list
|
40
50
|
(can provide multiple names separated by spaces)
|
41
51
|
s[hell] - opens an interactive pry shell (command line only)
|
42
52
|
t[ill] - returns when the desired Internet connection state is true. Options:
|
@@ -48,7 +58,6 @@ x[it] - exits this program (interactive shell mode only) (se
|
|
48
58
|
When in interactive shell mode:
|
49
59
|
* use quotes for string parameters such as method names.
|
50
60
|
* for pry commands, use prefix `%`.
|
51
|
-
|
52
61
|
```
|
53
62
|
|
54
63
|
Internally, it uses several Mac command line utilities. This is not ideal,
|
@@ -66,42 +75,20 @@ This is accomplished by the following command:
|
|
66
75
|
|
67
76
|
`gem install awesome_print`
|
68
77
|
|
78
|
+
You may need to precede this command with `sudo `, especially if you are using the
|
79
|
+
version of Ruby that comes packaged with MacOS.
|
69
80
|
|
70
|
-
### JSON and YAML Output
|
71
|
-
|
72
|
-
For now, JSON and YAML processing are only available in the interactive mode shell, in the way
|
73
|
-
you would usually use them in Ruby code. Their respective libraries are automatically
|
74
|
-
`require`d for your convenience. If you want them in non-interactive mode,
|
75
|
-
you can work around this limitation by redirecting the shell's input, e.g.:
|
76
81
|
|
77
|
-
|
78
|
-
echo "File.write('available_networks.json', availnets.pretty_inspect)" | mac-wifi s
|
79
|
-
```
|
82
|
+
### JSON and YAML Output
|
80
83
|
|
81
|
-
|
84
|
+
You can specify that output in _noninteractive_ mode be in JSON or YAML formats
|
85
|
+
by specifying `-j` or `-y` on the command line, respectively.
|
82
86
|
|
83
|
-
```bash
|
84
|
-
["....MMobile 2.4G",
|
85
|
-
".@ 3BB_WiFi",
|
86
|
-
".@ AIS SUPER WiFi"]
|
87
|
-
```
|
88
87
|
|
89
88
|
### Seeing the Underlying OS Commands and Output
|
90
89
|
|
91
|
-
If you would like to see the Mac OS commands and their output,
|
92
|
-
|
93
|
-
This can be done in the following ways (using the `info` command as an example):
|
94
|
-
|
95
|
-
```
|
96
|
-
export MAC_WIFI_OPTS=-v
|
97
|
-
./mac-wifi i
|
98
|
-
```
|
99
|
-
|
100
|
-
...or...
|
101
|
-
|
102
|
-
```
|
103
|
-
MAC_WIFI_OPTS=-v ./mac-wifi i
|
104
|
-
```
|
90
|
+
If you would like to see the Mac OS commands and their output,
|
91
|
+
you can do so by specifying "-v" on the command line.
|
105
92
|
|
106
93
|
You may notice that some commands are executed more than once. This is to simplify the application logic
|
107
94
|
and eliminate the need for the complexity of balancing the speed that a cache offers and the risk
|
@@ -122,6 +109,20 @@ sudo gem install pry-coolline
|
|
122
109
|
```
|
123
110
|
|
124
111
|
|
112
|
+
### Using It in Scripts
|
113
|
+
|
114
|
+
Sometimes calling `mac-wifi` from a script is handy. I have this script that
|
115
|
+
connects to a commonly used wifi network, and then speaks a message when it's done:
|
116
|
+
|
117
|
+
```
|
118
|
+
mac-wifi connect my_network_name my_password && \
|
119
|
+
mac-wifi till conn && \
|
120
|
+
say -v Kyoko "Connected to my network."
|
121
|
+
```
|
122
|
+
|
123
|
+
(The `say` command supports all kinds of accents that are fun to play around with.
|
124
|
+
You can get a list of all of them by running `say -v "?"`)
|
125
|
+
|
125
126
|
### Using the Shell
|
126
127
|
|
127
128
|
**If the program immediately exits when you try to run the shell, try upgrading `pry` and `pry-byebug`.
|
@@ -243,9 +244,9 @@ expression and don't need to print it out, you can simply append `;nil` to the e
|
|
243
244
|
and that will be value output to the console. For example:
|
244
245
|
|
245
246
|
```
|
246
|
-
[10] pry(#<MacWifi::CommandLineInterface>)> available_networks =
|
247
|
+
[10] pry(#<MacWifi::CommandLineInterface>)> available_networks = avail_nets; nil
|
247
248
|
=> nil
|
248
|
-
[11] pry(#<MacWifi::CommandLineInterface>)>
|
249
|
+
[11] pry(#<MacWifi::CommandLineInterface>)> avail_nets.size
|
249
250
|
=> 32
|
250
251
|
```
|
251
252
|
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## v2.0.0
|
2
|
+
|
3
|
+
* Support output formats in batch mode: JSON, YAML, puts, and inspect modes.
|
4
|
+
* Change some command names to include underscores.
|
5
|
+
* Shell mode is now (only) a command line switch (-s).
|
6
|
+
|
7
|
+
|
8
|
+
## v1.4.0
|
9
|
+
|
10
|
+
* Support for "MAC-WIFI-OPTS" environment variable for configuration dropped.
|
11
|
+
* Support for "-v" verbosity command line option added.
|
12
|
+
* Work around pry bug whereby shell was not always starting when requested.
|
13
|
+
* 99% fix for reporting of available network names containing leading spaces
|
14
|
+
(this will not correctly handle the case of network names that are identical
|
15
|
+
except for numbers of leading spaces).
|
16
|
+
* Improved handling of attempting to list available networks when wifi is off.
|
17
|
+
|
18
|
+
|
1
19
|
## v1.3.0
|
2
20
|
|
3
21
|
* Add partial JSON and YAML support.
|