-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from liquid-labs/work-liquid-labs/s3-empty-buck…
…et/5 Add quiet option
- Loading branch information
Showing
4 changed files
with
118 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
import { S3Client } from '@aws-sdk/client-s3' | ||
|
||
import commandLineArgs from 'command-line-args' | ||
|
||
import { getCredentials } from './lib/get-credentials' | ||
import { emptyBucket } from '../lib/s3-empty-bucket' | ||
|
||
const cliSpec = { | ||
mainCommand : 's3-empty-bucket', | ||
mainOptions : [ | ||
{ name : 'bucketName', defaultOption : true, description : 'The name of the bucket to empty.' }, | ||
{ name : 'profile', alias : 'p', description : 'The SSO profile to use.' }, | ||
{ name : 'quiet', alias : 'q', type : Boolean, description : 'Suppresses output.' } | ||
] | ||
} | ||
|
||
const s3EmptyBucket = () => { | ||
const bucketName = process.argv[2] | ||
const ssoProfile = process.argv[3] | ||
const options = commandLineArgs(cliSpec.mainOptions) | ||
const { bucketName, profile, quiet } = options | ||
|
||
const credentials = getCredentials({ ssoProfile }) | ||
const credentials = getCredentials({ ssoProfile : profile }) | ||
const s3Client = new S3Client({ credentials }) | ||
|
||
emptyBucket({ bucketName, s3Client }) | ||
emptyBucket({ bucketName, s3Client, verbose : !quiet }) | ||
} | ||
|
||
export { s3EmptyBucket } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters