Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 141d502

Browse files
committed
Tighten types
1 parent a5038f4 commit 141d502

File tree

8 files changed

+24
-14
lines changed

8 files changed

+24
-14
lines changed

src/cli/commands/access-codes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default {
1515
return yargs.option("device-id", {
1616
describe: "filter by device ID",
1717
demandOption: true,
18+
type: "string",
1819
})
1920
},
2021
async (argv) => {
@@ -37,9 +38,11 @@ export default {
3738
.option("device-id", {
3839
describe: "the device ID",
3940
demandOption: true,
41+
type: "string",
4042
})
4143
.option("name", {
4244
describe: "the name of the access code",
45+
type: "string",
4346
})
4447
.option("code", {
4548
describe: "the code",
@@ -80,6 +83,7 @@ export default {
8083
return yargs.positional("id", {
8184
describe: "the access code ID",
8285
demandOption: true,
86+
type: "string",
8387
})
8488
},
8589
async (argv) => {

src/cli/commands/action-attempts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default {
1313
return yargs.positional("id", {
1414
describe: "the action attempt ID",
1515
demandOption: true,
16+
type: "string",
1617
})
1718
},
1819
async (argv) => {

src/cli/commands/connect-webviews.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default {
2424
return yargs.positional("id", {
2525
describe: "the connect webview ID",
2626
demandOption: true,
27+
type: "string",
2728
})
2829
},
2930
async (argv) => {
@@ -56,7 +57,7 @@ export default {
5657
"connectWebviews.create",
5758
[
5859
{
59-
accepted_providers: argv["accepted-providers"],
60+
accepted_providers: argv["accepted-providers"] as Provider[],
6061
},
6162
],
6263
argv

src/cli/commands/connected-accounts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default {
2323
return yargs.positional("id", {
2424
describe: "the connected account ID",
2525
demandOption: true,
26+
type: "string",
2627
})
2728
},
2829
async (argv) => {

src/cli/commands/devices.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default {
1515
return yargs.positional("id", {
1616
describe: "the device ID",
1717
demandOption: true,
18+
type: "string",
1819
})
1920
},
2021
async (argv) => {

src/cli/commands/locks.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default {
1515
return yargs.positional("id", {
1616
describe: "the lock ID",
1717
demandOption: true,
18+
type: "string",
1819
})
1920
},
2021
async (argv) => {
@@ -42,6 +43,7 @@ export default {
4243
return yargs.positional("id", {
4344
describe: "the lock ID",
4445
demandOption: true,
46+
type: "string",
4547
})
4648
},
4749
async (argv) => {
@@ -55,6 +57,7 @@ export default {
5557
return yargs.positional("id", {
5658
describe: "the lock ID",
5759
demandOption: true,
60+
type: "string",
5861
})
5962
},
6063
async (argv) => {

src/cli/commands/workspaces.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,11 @@ export default {
99
yargs
1010
.demandCommand()
1111
.command(
12-
"get <id>",
13-
"get a workspace",
14-
(yargs) => {
15-
return yargs.positional("id", {
16-
describe: "the workspace ID",
17-
demandOption: true,
18-
})
19-
},
12+
"get",
13+
"get the workspace associated with the current API key",
14+
() => {},
2015
async (argv) => {
21-
await executeCommand("workspaces.get", [argv.id], argv)
16+
await executeCommand("workspaces.get", [], argv)
2217
}
2318
)
2419
.command(

src/cli/execute-command.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import ora from "ora"
2+
import { Get } from "type-fest"
23
import { paramCase } from "change-case"
34
import Seam, { SeamAPIError } from ".."
45

5-
// todo: tighten types for args
6-
const executeCommand = async (
7-
methodName: string,
8-
args: any[],
6+
type ParametersByPath<Path extends string> = Parameters<
7+
Exclude<Get<Seam, Path>, Seam>
8+
>
9+
10+
const executeCommand = async <MethodPath extends string>(
11+
methodName: MethodPath,
12+
args: ParametersByPath<MethodPath>,
913
executeArgs: { json?: boolean; quiet?: boolean }
1014
) => {
1115
const displaySpinner = !(executeArgs.quiet || executeArgs.json)

0 commit comments

Comments
 (0)