Skip to content

Commit

Permalink
make token delete use scope
Browse files Browse the repository at this point in the history
  • Loading branch information
codekeyz committed Dec 4, 2024
1 parent af1971f commit 30acc1d
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:mason_logger/mason_logger.dart';

import '../../command.dart';
import '../../utils/api.dart';
import '../../utils/prompts.dart';

class TokenDeleteCommand extends BaseGlobeCommand {
TokenDeleteCommand() {
Expand All @@ -23,19 +22,16 @@ class TokenDeleteCommand extends BaseGlobeCommand {
@override
FutureOr<int> run() async {
requireAuth();
await scope.selectOrLinkNewScope();

final organization = await selectOrganization(logger: logger, api: api);
final tokenId = (argResults?['tokenId'] as String?) ??
logger.prompt('❓ Provide id for token:');

final deleteTokenProgress =
logger.progress('Deleting Token: ${cyan.wrap(tokenId)}');

try {
await api.deleteToken(
orgId: organization.id,
tokenId: tokenId,
);
await api.deleteToken(orgId: scope.current!.orgId, tokenId: tokenId);
deleteTokenProgress.complete('Token deleted');
} on ApiException catch (e) {
deleteTokenProgress.fail('✗ Failed to delete token: ${e.message}');
Expand Down

0 comments on commit 30acc1d

Please sign in to comment.