Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch 'press-any-key' to 'press-ctrl-C'. #125

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/commands/tail-cloudwatch-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TailCloudwatchLogsCommand extends Command {
const logGroupName = await this.getLogGroupName(namePrefix);

this.log(`polling CLoudWatch log group [${logGroupName}]...`);
this.log("press <any key> to stop");
this.log("press ctrl+C to stop");
await this.pollLogGroup(logGroupName);

this.exit(0);
Expand Down Expand Up @@ -94,9 +94,11 @@ class TailCloudwatchLogsCommand extends Command {
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
const stdin = process.openStdin();
stdin.once("keypress", () => {
polling = false;
this.log("stopping...");
stdin.on("keypress", async (data, key) => {
if (key && key.ctrl && key.name == "c") {
polling = false;
this.log("stopping...");
}
});

const fetch = async (startTime, endTime, nextToken, acc = []) => {
Expand Down
10 changes: 6 additions & 4 deletions src/commands/tail-dynamodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TailDynamodbCommand extends Command {
this.log(
`polling DynamoDB stream for table [${tableName}] (${stream.shardIds.length} shards)...`
);
this.log("press <any key> to stop");
this.log("press ctrl-C to stop");
await this.pollDynamoDBStreams(streamArn, stream.shardIds);

this.exit(0);
Expand Down Expand Up @@ -91,9 +91,11 @@ class TailDynamodbCommand extends Command {
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
const stdin = process.openStdin();
stdin.once("keypress", () => {
polling = false;
this.log("stopping...");
stdin.on("keypress", async (data, key) => {
if (key && key.ctrl && key.name == "c") {
polling = false;
this.log("stopping...");
}
});

const promises = shardIds.map(async shardId => {
Expand Down
15 changes: 8 additions & 7 deletions src/commands/tail-eventbridge-rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,20 @@ class TailEventbridgeRuleCommand extends Command {
await this.addTarget(queueArn);

this.log(`polling event rule [${ruleArn}]...`);
this.log("press <any key> to stop");
this.log("press ctrl-C to stop");

let polling = true;
const readline = require("readline");
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
const stdin = process.openStdin();
stdin.once("keypress", async () => {
polling = false;
this.log("stopping...");

await this.removeTarget();
await this.deleteQueue(queueUrl);
stdin.on("keypress", async (data, key) => {
if (key && key.ctrl && key.name == "c") {
this.log("stopping...");
polling = false;
await this.removeTarget();
await this.deleteQueue(queueUrl);
}
});

const AWS = getAWSSDK();
Expand Down
10 changes: 6 additions & 4 deletions src/commands/tail-kinesis.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TailKinesisCommand extends Command {
this.log(
`polling Kinesis stream [${streamName}] (${stream.shardIds.length} shards)...`
);
this.log("press <any key> to stop");
this.log("press ctrl-C to stop");
await this.pollKinesis(streamName, stream.shardIds);
}

Expand Down Expand Up @@ -63,9 +63,11 @@ class TailKinesisCommand extends Command {
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
const stdin = process.openStdin();
stdin.once("keypress", () => {
polling = false;
this.log("stopping...");
stdin.on("keypress", async (data, key) => {
if (key && key.ctrl && key.name == "c") {
polling = false;
this.log("stopping...");
}
});

const promises = shardIds.map(async shardId => {
Expand Down
14 changes: 8 additions & 6 deletions src/commands/tail-sns.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,21 @@ class TailSnsCommand extends Command {
const subscriptionArn = await this.subscribeToSNS(topicArn, queueArn);

this.log(`polling SNS topic [${topicArn}]...`);
this.log("press <any key> to stop");
this.log("press ctrl-C to stop");

let polling = true;
const readline = require("readline");
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
const stdin = process.openStdin();
stdin.once("keypress", async () => {
polling = false;
this.log("stopping...");
stdin.on("keypress", async (data, key) => {
if (key && key.ctrl && key.name == "c") {
polling = false;
this.log("stopping...");

await this.unsubscribeFromSNS(subscriptionArn);
await this.deleteQueue(queueUrl);
await this.unsubscribeFromSNS(subscriptionArn);
await this.deleteQueue(queueUrl);
}
});

const AWS = getAWSSDK();
Expand Down
12 changes: 7 additions & 5 deletions src/commands/tail-sqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TailSqsCommand extends Command {
const queueUrl = await getQueueUrl(queueName);

this.log(`polling SQS queue [${queueUrl}]...`);
this.log("press <any key> to stop");
this.log("press ctrl-C to stop");
await this.pollSqs(queueUrl);

this.exit(0);
Expand All @@ -40,10 +40,12 @@ class TailSqsCommand extends Command {
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
const stdin = process.openStdin();
stdin.once("keypress", () => {
polling = false;
this.log("stopping...");
seenMessageIds = new Set();
stdin.on("keypress", async (data, key) => {
if (key && key.ctrl && key.name == "c") {
polling = false;
this.log("stopping...");
seenMessageIds = new Set();
}
});

// eslint-disable-next-line no-constant-condition
Expand Down