FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
simctl/program.js at master · lsongdev/simctl · GitHub
lsongdev
/
simctl
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
3
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
simctl
/
program.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (36 loc) · 936 Bytes
Breadcrumbs
simctl
/
program.js
Copy path
File metadata and controls
39 lines (36 loc) · 936 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const
parse
=
argv
=>
argv
.
reduce
(
(
args
,
value
)
=>
{
if
(
value
.
startsWith
(
'--'
)
)
{
const
m
=
value
.
match
(
/
^
-
-
(
\w
+
)
(
=
(
.
+
)
)
?
$
/
)
;
const
k
=
m
[
1
]
;
const
v
=
m
[
3
]
?
m
[
3
]
:
true
;
args
[
k
]
=
v
;
}
else
{
args
.
_
.
push
(
value
)
;
}
return
args
;
}
,
{
_
:
[
]
}
)
;
const
program
=
options
=>
{
const
interface
=
{
command
(
name
,
fn
)
{
this
.
commands
=
this
.
commands
||
{
}
;
this
.
commands
[
name
]
=
fn
;
return
this
;
}
,
exec
(
name
=
'help'
)
{
const
fn
=
this
.
commands
[
name
]
;
if
(
typeof
fn
!==
'function'
)
{
throw
new
TypeError
(
`command "
${
name
}
" not found`
)
;
}
return
fn
.
apply
(
this
,
[
]
.
slice
.
call
(
arguments
,
1
)
)
;
}
,
parse
(
argv
=
process
.
argv
.
slice
(
2
)
)
{
const
args
=
parse
(
argv
)
;
const
name
=
args
.
_
.
shift
(
)
;
return
this
.
exec
(
name
,
args
)
;
}
}
;
return
interface
;
}
;
program
.
parse
=
parse
;
module
.
exports
=
program
;
Back
|
FazBrowse Home
|
New Git URL