-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a47662
commit 60509a0
Showing
13 changed files
with
1,254 additions
and
754 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#! /nix/store/5lr5n3qa4day8l1ivbwlcby2nknczqkq-bash-5.2p26/bin/bash -e | ||
exec -a "$0" "/nix/store/rlv9fcq70pniyrm3xy21wgk5rdhdh12h-nodejs-20.11.1/bin/node" /home/mloeper/nesto/repos/nesto-software/s3-browser-cli/outputs/out/index.js "$@" |
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env node | ||
import inquirer from "inquirer"; | ||
import inquirer_s3 from "inquirer-s3"; | ||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
import fs from "fs"; | ||
|
||
inquirer.registerPrompt('s3-object', inquirer_s3); | ||
|
||
// workaround, see README | ||
const fd3 = fs.createWriteStream(null, {fd: 3}); | ||
|
||
// note: move into nix env | ||
process.env.AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE = '1'; | ||
|
||
yargs(hideBin(process.argv)) | ||
.command('*', 'start the interactive s3 key selection', (yargs) => { | ||
return yargs | ||
.option('bucket', { | ||
type: "string", | ||
describe: 'A bucket to pre-select. When specifying the bucket parameter with the name of a valid S3 account owned by your AWS account, the inquirer-s3 module will start to browse at the root of this bucket' | ||
}) | ||
.option('objectPrefix', { | ||
type: "string", | ||
alias: "key", | ||
describe: "An S3 object prefix indicating where you'd like to start the browsing inside a bucket", | ||
}) | ||
.option('enableFolderSelect', { | ||
type: "boolean", | ||
alias: "folders", | ||
describe: " If set, the user is allowed to select an S3 *folder* prefix as a valid result, default false" | ||
}) | ||
.option('enableFileObjectSelect', { | ||
type: "boolean", | ||
alias: "files", | ||
describe: "If set, the user is allowed to select an S3 object (*files*) as a valid result, default true", | ||
}) | ||
.option('enableOtherBuckets', { | ||
type: "boolean", | ||
alias: "allow-switch", | ||
describe: "If set, the user should be allowed to navigate to buckets other than the bucket parameter specified, default true", | ||
}) | ||
.option('redirect', { | ||
type: "boolean", | ||
default: false, | ||
describe: "Use fd3 to write the command output instead of fd1 - ideal for programmatic access such as using jq", | ||
}) | ||
}, async (argv) => { | ||
const res = await inquirer.prompt([{ | ||
type: 's3-object', | ||
name: 'result', | ||
message: 'Which S3 object would you like to select?', | ||
bucket: argv.bucket, | ||
objectPrefix: argv.objectPrefix, | ||
enableFolderSelect: argv.enableFolderSelect, | ||
enableFileObjectSelect: argv.enableFileObjectSelect, | ||
enableOtherBuckets: argv.enableOtherBuckets, | ||
}]); | ||
|
||
let out = ""; | ||
if (res && res.result) { | ||
out = JSON.stringify(res.result); | ||
} else { | ||
out = "{}"; | ||
} | ||
|
||
// check if user wants to access the output programmatically | ||
if (argv.redirect) { | ||
fd3.write(out); | ||
console.log("Wrote result to fd3."); | ||
} else { | ||
console.log(out); | ||
} | ||
}) | ||
.strict() | ||
.parse(); |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/nix/store/0ysg0v90s45lmj6lzq4zxsgybww8hb2x-node-dependencies-s3-browser-cli-1.0.1/lib/node_modules |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "s3-browser-cli", | ||
"version": "1.0.1", | ||
"type": "module", | ||
"description": "An s3 browser cli binary to select files interactively", | ||
"main": "index.js", | ||
"author": "Martin Löper <[email protected]>", | ||
"repository": "https://github.com/nesto-software/s3-browser-cli", | ||
"license": "MIT", | ||
"bin": { | ||
"s3select": "./index.js" | ||
}, | ||
"scripts": { | ||
"start": "node index.js", | ||
"rjson": "rjson" | ||
}, | ||
"dependencies": { | ||
"inquirer": "^1.2.3", | ||
"@nesto-software/inquirer-s3": "1.0.2", | ||
"yargs": "^17.7.2" | ||
}, | ||
"devDependencies": { | ||
"@types/inquirer": "^7.3.3", | ||
"@types/yargs": "^17.0.32" | ||
} | ||
} |
Oops, something went wrong.