Skip to content

Commit

Permalink
Merge pull request #701 from guardian/sg/make-cli-verbose
Browse files Browse the repository at this point in the history
feat: Make cli verbose by default
  • Loading branch information
samanthagottlieb authored Jul 21, 2021
2 parents 0e997de + 0dd4811 commit 9212b83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
17 changes: 3 additions & 14 deletions src/bin/commands/account-readiness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import type { CliCommandResponse } from "../../types/command";
export const accountReadinessCommand = async ({
credentialProvider,
region,
verbose,
}: {
credentialProvider: CredentialProviderChain;
region: string;
verbose: boolean;
}): CliCommandResponse => {
const ssm = new AWS.SSM({
credentialProvider,
Expand All @@ -22,18 +20,9 @@ export const accountReadinessCommand = async ({

const awsResponse = await ssm.getParameters({ Names: paths }).promise();

const foundParameters = awsResponse.Parameters ?? [];
const notFoundParameters = awsResponse.InvalidParameters ?? [];

if (!verbose) {
const messagePrefix = notFoundParameters.length === 0 ? "OK" : "ACTION NEEDED";

return Promise.resolve(
`[${messagePrefix}] ${foundParameters.length}/${ssmParams.length} SSM parameters found. ${notFoundParameters.length}/${ssmParams.length} SSM parameters not found.`
);
} else {
const notFoundInDetail = ssmParams.filter((_) => notFoundParameters.includes(_.path));
const foundInDetail = ssmParams.filter((_) => !notFoundParameters.includes(_.path));
return Promise.resolve({ found: foundInDetail, notFound: notFoundInDetail });
}
const notFoundInDetail = ssmParams.filter((_) => notFoundParameters.includes(_.path));
const foundInDetail = ssmParams.filter((_) => !notFoundParameters.includes(_.path));
return Promise.resolve({ found: foundInDetail, notFound: notFoundInDetail });
};
4 changes: 2 additions & 2 deletions src/bin/commands/aws-cdk-version.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LibraryInfo } from "../../constants/library-info";
import type { CliCommandResponse } from "../../types/command";

export const awsCdkVersionCommand = (verbose: boolean): CliCommandResponse => {
return Promise.resolve(verbose ? LibraryInfo.AWS_CDK_VERSIONS : LibraryInfo.AWS_CDK_VERSION);
export const awsCdkVersionCommand = (): CliCommandResponse => {
return Promise.resolve(LibraryInfo.AWS_CDK_VERSIONS);
};
7 changes: 3 additions & 4 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const parseCommandLineArguments = () => {
return Promise.resolve(
yargs
.usage("$0 COMMAND [args]")
.option("verbose", { type: "boolean", default: false, description: "Show verbose output" })
.option("profile", { type: "string", description: "AWS profile" })
.option("region", { type: "string", description: "AWS region", default: "eu-west-1" })
.command(Commands.AwsCdkVersion, "Print the version of @aws-cdk libraries being used")
Expand All @@ -37,12 +36,12 @@ const parseCommandLineArguments = () => {
parseCommandLineArguments()
.then((argv): CliCommandResponse => {
const command = argv._[0];
const { verbose, profile, region } = argv;
const { profile, region } = argv;
switch (command) {
case Commands.AwsCdkVersion:
return awsCdkVersionCommand(verbose);
return awsCdkVersionCommand();
case Commands.AccountReadiness:
return accountReadinessCommand({ credentialProvider: awsCredentialProviderChain(profile), region, verbose });
return accountReadinessCommand({ credentialProvider: awsCredentialProviderChain(profile), region });
default:
throw new Error(`Unknown command: ${command}`);
}
Expand Down

0 comments on commit 9212b83

Please sign in to comment.