This repository was archived by the owner on Nov 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +105
-0
lines changed
Expand file tree Collapse file tree 3 files changed +105
-0
lines changed Original file line number Diff line number Diff line change 1+ import executeCommand from "../execute-command"
2+ import { YargsWithGlobalOptions } from "../global-options"
3+
4+ export default {
5+ command : "devices" ,
6+ aliases : [ "device" ] ,
7+ describe : "interact with devices" ,
8+ builder : ( yargs : YargsWithGlobalOptions ) => {
9+ yargs
10+ . demandCommand ( )
11+ . command (
12+ "get <id>" ,
13+ "get a device" ,
14+ ( yargs ) => {
15+ return yargs . positional ( "id" , {
16+ describe : "the device ID" ,
17+ demandOption : true ,
18+ } )
19+ } ,
20+ async ( argv ) => {
21+ await executeCommand ( "devices.get" , [ argv . id ] , argv )
22+ }
23+ )
24+ . command (
25+ "list" ,
26+ "list devices" ,
27+ ( yargs ) => {
28+ return yargs . option ( "connected-account-id" , {
29+ describe : "filter by connected account ID" ,
30+ type : "string" ,
31+ alias : "ca" ,
32+ } )
33+ } ,
34+ async ( argv ) => {
35+ await executeCommand ( "devices.list" , [ argv . connectedAccountId ] , argv )
36+ }
37+ )
38+ } ,
39+ }
Original file line number Diff line number Diff line change 1+ import executeCommand from "../execute-command"
2+ import { YargsWithGlobalOptions } from "../global-options"
3+
4+ export default {
5+ command : "locks" ,
6+ aliases : [ "lock" ] ,
7+ describe : "interact with locks" ,
8+ builder : ( yargs : YargsWithGlobalOptions ) => {
9+ yargs
10+ . demandCommand ( )
11+ . command (
12+ "get <id>" ,
13+ "get a lock" ,
14+ ( yargs ) => {
15+ return yargs . positional ( "id" , {
16+ describe : "the lock ID" ,
17+ demandOption : true ,
18+ } )
19+ } ,
20+ async ( argv ) => {
21+ await executeCommand ( "locks.get" , [ argv . id ] , argv )
22+ }
23+ )
24+ . command (
25+ "list" ,
26+ "list locks" ,
27+ ( yargs ) => {
28+ return yargs . option ( "connected-account-id" , {
29+ describe : "filter by connected account ID" ,
30+ type : "string" ,
31+ alias : "ca" ,
32+ } )
33+ } ,
34+ async ( argv ) => {
35+ await executeCommand ( "locks.list" , [ argv . connectedAccountId ] , argv )
36+ }
37+ )
38+ . command (
39+ "lock-door <id>" ,
40+ "lock a door" ,
41+ ( yargs ) => {
42+ return yargs . positional ( "id" , {
43+ describe : "the lock ID" ,
44+ demandOption : true ,
45+ } )
46+ } ,
47+ async ( argv ) => {
48+ await executeCommand ( "locks.lockDoor" , [ argv . id ] , argv )
49+ }
50+ )
51+ . command (
52+ "unlock-door <id>" ,
53+ "unlock a door" ,
54+ ( yargs ) => {
55+ return yargs . positional ( "id" , {
56+ describe : "the lock ID" ,
57+ demandOption : true ,
58+ } )
59+ } ,
60+ async ( argv ) => {
61+ await executeCommand ( "locks.unlockDoor" , [ argv . id ] , argv )
62+ }
63+ )
64+ } ,
65+ }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import ora from "ora"
22import { paramCase } from "change-case"
33import Seam , { SeamAPIError } from ".."
44
5+ // todo: tighten types for args
56const executeCommand = async (
67 methodName : string ,
78 args : any [ ] ,
You can’t perform that action at this time.
0 commit comments