Skip to content

Commit 2a49d85

Browse files
committed
Address PR comments
1 parent fd4c106 commit 2a49d85

4 files changed

Lines changed: 7 additions & 41 deletions

File tree

src/commands/auth/keys/current.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class KeysCurrentCommand extends ControlBaseCommand {
4040
this.fail(
4141
`No API key configured for app ${appId}. Use "ably auth keys switch" to select a key.`,
4242
flags,
43-
"KeyCurrent",
43+
"keyCurrent",
4444
);
4545
}
4646

@@ -97,7 +97,7 @@ export default class KeysCurrentCommand extends ControlBaseCommand {
9797
this.fail(
9898
"ABLY_API_KEY environment variable is not set",
9999
flags,
100-
"KeyCurrent",
100+
"keyCurrent",
101101
);
102102
}
103103

src/commands/auth/keys/revoke.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,12 @@ export default class KeysRevokeCommand extends ControlBaseCommand {
3838
async run(): Promise<void> {
3939
const { args, flags } = await this.parse(KeysRevokeCommand);
4040

41-
let appId: string | undefined;
4241
let keyId = args.keyName;
4342

4443
const parsed = parseKeyIdentifier(args.keyName);
45-
if (parsed.appId) appId = parsed.appId;
4644
keyId = parsed.keyId;
4745

48-
if (!appId) {
49-
const resolved = await this.resolveAppId(flags);
50-
if (!resolved) {
51-
this.fail(
52-
'No app specified. Use --app flag, provide APP_ID.KEY_ID as the argument, or select an app with "ably apps switch"',
53-
flags,
54-
"keyRevoke",
55-
);
56-
}
57-
appId = resolved;
58-
}
46+
const appId = parsed.appId ?? (await this.requireAppId(flags));
5947

6048
try {
6149
const controlApi = this.createControlApi(flags);

src/commands/auth/keys/switch.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,16 @@ export default class KeysSwitchCommand extends ControlBaseCommand {
3333
async run(): Promise<void> {
3434
const { args, flags } = await this.parse(KeysSwitchCommand);
3535

36-
let appId: string | undefined;
3736
let keyId: string | undefined = args.keyNameOrValue;
37+
let extractedAppId: string | undefined;
3838

3939
if (args.keyNameOrValue) {
4040
const parsed = parseKeyIdentifier(args.keyNameOrValue);
41-
if (parsed.appId) appId = parsed.appId;
41+
if (parsed.appId) extractedAppId = parsed.appId;
4242
keyId = parsed.keyId;
4343
}
4444

45-
if (!appId) {
46-
const resolved = await this.resolveAppId(flags);
47-
if (!resolved) {
48-
this.fail(
49-
'No app specified. Use --app flag, provide APP_ID.KEY_ID as the argument, or select an app with "ably apps switch"',
50-
flags,
51-
"keySwitch",
52-
);
53-
}
54-
appId = resolved;
55-
}
45+
const appId = extractedAppId ?? (await this.requireAppId(flags));
5646

5747
try {
5848
const controlApi = this.createControlApi(flags);

src/commands/auth/keys/update.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,12 @@ export default class KeysUpdateCommand extends ControlBaseCommand {
4949
);
5050
}
5151

52-
let appId: string | undefined;
5352
let keyId = args.keyName;
5453

5554
const parsed = parseKeyIdentifier(args.keyName);
56-
if (parsed.appId) appId = parsed.appId;
5755
keyId = parsed.keyId;
5856

59-
if (!appId) {
60-
const resolved = await this.resolveAppId(flags);
61-
if (!resolved) {
62-
this.fail(
63-
'No app specified. Use --app flag, provide APP_ID.KEY_ID as the argument, or select an app with "ably apps switch"',
64-
flags,
65-
"keyUpdate",
66-
);
67-
}
68-
appId = resolved;
69-
}
57+
const appId = parsed.appId ?? (await this.requireAppId(flags));
7058

7159
try {
7260
const controlApi = this.createControlApi(flags);

0 commit comments

Comments
 (0)