File tree Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Original file line number Diff line number Diff line change
1
+ import '@jxa/global-type'
2
+ import type { Selection } from './types'
3
+
4
+ const app = Application . currentApplication ( )
5
+ app . includeStandardAdditions = true
6
+
7
+ const getIntranetIP = ( ) => ( app . systemInfo ( ) as any ) . ipv4Address
8
+
9
+ export const parsePort = ( port : string ) : Selection => {
10
+ return {
11
+ title : `Port:${ port } ` ,
12
+ subtitle : `http://localhost:${ port } ` ,
13
+ arg : `localhost:${ port } ` ,
14
+ mods : {
15
+ cmd : {
16
+ subtitle : `http://127.0.0.1:${ port } ` ,
17
+ arg : `127.0.0.1:${ port } ` ,
18
+ } ,
19
+ ctrl : {
20
+ subtitle : `http://${ getIntranetIP ( ) } :${ port } ` ,
21
+ arg : `${ getIntranetIP ( ) } :${ port } ` ,
22
+ } ,
23
+ } ,
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ import { parsePort } from './core'
1
2
import type { Selection } from './types'
2
3
3
- export default function run ( argv : Array < string | boolean > ) {
4
+ export default function run ( argv : [ string , boolean ] ) {
4
5
const query = argv [ 0 ]
6
+ const items = [ ]
7
+ items . push ( parsePort ( '8080' ) )
8
+ const currPort = parsePort ( query )
9
+ query && items . push ( currPort )
10
+
5
11
const result : {
6
12
items : Selection [ ]
7
13
} = {
8
- items : [ {
9
- title : `This is a selection example, and you are inputing ${ query } ` ,
10
- } ] ,
14
+ items,
11
15
}
12
16
13
17
// for testing
Original file line number Diff line number Diff line change @@ -23,21 +23,21 @@ export interface Selection {
23
23
24
24
}
25
25
26
- export type Mod = Record < ModComb , ModItem >
26
+ export type Mod = Partial < Record < ModComb , ModItem > >
27
27
28
28
export type ModNames = 'cmd' | 'alt' | 'ctrl' | 'shift' | 'fn'
29
29
30
30
export type t = {
31
31
[ k in ModNames ] : {
32
- [ v in ModNames ] : k extends v ? v extends k ? never : `${k } + ${v } ` : `${k } + ${v } `
32
+ [ v in ModNames ] : k extends v ? v extends k ? v : `${k } + ${v } ` : `${k } + ${v } `
33
33
}
34
34
}
35
35
36
36
// the same key combinations is not allowed, 'fn + fn' e.g.
37
37
export type ModComb = `${t [ ModNames ] [ ModNames ] } `
38
38
39
39
export interface ModItem {
40
- valid : string
40
+ valid ? : string
41
41
arg : string
42
42
subtitle : string
43
43
}
You can’t perform that action at this time.
0 commit comments