|
16 | 16 |
|
17 | 17 | import { Arguments, Registrar } from "@kui-shell/core" |
18 | 18 |
|
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[]> { |
20 | 26 | const { join } = await import("path") |
21 | 27 | await import("@kui-shell/plugin-s3").then((_) => _.enable()) |
22 | 28 | return args.argvNoOptions.slice(3).map((_) => join("/s3", _)) |
23 | 29 | } |
24 | 30 |
|
| 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 */ |
25 | 41 | async function ls(args: Arguments) { |
26 | | - return args.REPL.qexec("ls " + (await dirs(args)).join(" ")) |
| 42 | + return args.REPL.qexec("ls " + (await rest(args))) |
27 | 43 | } |
28 | 44 |
|
| 45 | +/** (TODO) A Kui controller that allows the user to select a filepath, while browsing */ |
29 | 46 | async function select(args: Arguments) { |
30 | | - return args.REPL.qexec("ls " + (await dirs(args)).join(" ")) |
| 47 | + return args.REPL.qexec("ls " + (await rest(args))) |
31 | 48 | } |
32 | 49 |
|
33 | 50 | export default function s3Behaviors(registrar: Registrar) { |
|
0 commit comments