Skip to content

Commit 5aa6261

Browse files
committed
chore: minor code cleanup to s3 logic
1 parent b4cf09a commit 5aa6261

File tree

1 file changed

+20
-3
lines changed
  • plugins/plugin-codeflare/src/controller

1 file changed

+20
-3
lines changed

plugins/plugin-codeflare/src/controller/s3.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,35 @@
1616

1717
import { Arguments, Registrar } from "@kui-shell/core"
1818

19-
async function dirs(args: Arguments) {
19+
/**
20+
* @return the filepaths as specified on the command line, but
21+
* modified to be in a filepath format that is compatible with Kui's
22+
* plugin-s3; mostly this means prepending '/s3/' to each filepath
23+
* provided on the initial command line
24+
*/
25+
async function dirs(args: Arguments): Promise<string[]> {
2026
const { join } = await import("path")
2127
await import("@kui-shell/plugin-s3").then((_) => _.enable())
2228
return args.argvNoOptions.slice(3).map((_) => join("/s3", _))
2329
}
2430

31+
/**
32+
* @return a suffix command line that can be used to enumerate a set
33+
* of filepaths as specified on the command line; if none are
34+
* provided, defaults to list all recognized s3 providers
35+
*/
36+
async function rest(args: Arguments): Promise<string> {
37+
return (await dirs(args)).join(" ") || "/s3"
38+
}
39+
40+
/** A Kui controller that provides CLI experience for browsing s3 */
2541
async function ls(args: Arguments) {
26-
return args.REPL.qexec("ls " + (await dirs(args)).join(" "))
42+
return args.REPL.qexec("ls " + (await rest(args)))
2743
}
2844

45+
/** (TODO) A Kui controller that allows the user to select a filepath, while browsing */
2946
async function select(args: Arguments) {
30-
return args.REPL.qexec("ls " + (await dirs(args)).join(" "))
47+
return args.REPL.qexec("ls " + (await rest(args)))
3148
}
3249

3350
export default function s3Behaviors(registrar: Registrar) {

0 commit comments

Comments
 (0)