File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1
1
const meow = require ( 'meow' )
2
2
3
3
const slack = require ( './slack' )
4
+ const tabs = require ( './tabs' )
4
5
const { start, succeed, fail } = require ( './helpers' )
5
6
6
7
const at = ( input , flags ) => slack . status ( input [ 1 ] || '' )
@@ -23,6 +24,13 @@ switch (cli.input[0]) {
23
24
. then ( status => succeed ( `New status: ${ status . status_text } ` ) )
24
25
. catch ( err => fail ( err ) )
25
26
break
27
+ case 'tabs' :
28
+ tabs ( cli )
29
+ . then ( ( { safari, chrome, total } ) => {
30
+ succeed ( `\n Safari: ${ safari . tabs } /${ safari . windows } \n Chrome: ${ chrome . tabs } /${ chrome . windows } \n Total: ${ total . tabs } /${ total . windows } ` )
31
+ } )
32
+ . catch ( err => fail ( err ) )
33
+ break
26
34
default :
27
35
cli . showHelp ( )
28
36
break
Original file line number Diff line number Diff line change
1
+ const { promisify} = require ( 'util' )
2
+ const exec = promisify ( require ( 'child_process' ) . exec )
3
+
4
+ module . exports = ( cli ) => new Promise ( async ( resolve , reject ) => {
5
+ const results = {
6
+ safari : {
7
+ windows : 0 ,
8
+ tabs : 0 ,
9
+ } ,
10
+ chrome : {
11
+ windows : 0 ,
12
+ tabs : 0 ,
13
+ } ,
14
+ total : {
15
+ windows : 0 ,
16
+ tabs : 0 ,
17
+ } ,
18
+ }
19
+ results . safari . windows = parseInt ( ( await exec ( 'osascript -e \'tell application "Safari" to get count of windows\'' ) ) . stdout , 10 )
20
+ results . safari . tabs = parseInt ( ( await exec ( 'osascript -e \'tell application "Safari" to get count of tabs of windows\'' ) ) . stdout , 10 )
21
+
22
+ results . chrome . windows = parseInt ( ( await exec ( 'osascript -e \'tell application "Google Chrome" to get count of windows\'' ) ) . stdout , 10 )
23
+ results . chrome . tabs = parseInt ( ( await exec ( 'osascript -e \'tell application "Google Chrome" to get count of tabs of windows\'' ) ) . stdout , 10 )
24
+
25
+ results . total . windows = results . safari . windows + results . chrome . windows
26
+ results . total . tabs = results . safari . tabs + results . chrome . tabs
27
+
28
+ resolve ( results )
29
+ } )
You can’t perform that action at this time.
0 commit comments