Skip to content

Commit

Permalink
add logging for completions
Browse files Browse the repository at this point in the history
  • Loading branch information
echo-bravo-yahoo committed Nov 26, 2024
1 parent fa138cc commit d982c34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
15 changes: 8 additions & 7 deletions src/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,22 @@ function buildYargs(argvInput) {
.strict(true)
.completion(
"completion",
function (currentWord, argv, completionFilter, done) {
function (currentWord, argv, defaultCompletions, done) {
const logger = container.resolve("logger");
const previousWord = process.argv.slice(-2, -1)[0].replace(/-/g, "");
const currentWordFlag = Object.keys(argv)
.filter((key) => previousWord === key)
.pop();
// console.log("currentWord", currentWord);
// console.log("previousWord", previousWord);
// console.log("argv", JSON.stringify(argv, null, 2));
// console.log("currentWordFlag", currentWordFlag);
logger.debug(
`Parsing completions with current word ${currentWord} (for flag ${currentWordFlag}) and previous word ${previousWord}.`,
"completion",
);

// TODO: this doesn't handle aliasing, and it needs to
if (currentWord === "--dir" || currentWordFlag === "dir") {
getDirCompletions(currentWord, done);
} else {
completionFilter();
defaultCompletions();
}
},
)
Expand Down Expand Up @@ -163,7 +164,7 @@ function buildYargs(argvInput) {
"components to emit diagnostic logs for; this takes precedence over the 'verbosity' flag",
type: "array",
default: [],
choices: ["fetch", "error", "argv"],
choices: ["fetch", "error", "argv", "completion"],
},
// Whether authNZ middleware should run. Better way of doing this?
authRequired: {
Expand Down
6 changes: 0 additions & 6 deletions src/lib/completions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ function getDirInfo(possiblePath) {
}

export function getDirCompletions(currentWord, done) {
// console.log("currentWord", currentWord);
// console.log("previousWord", previousWord);
// console.log("argv", JSON.stringify(argv, null, 2));
// console.log("matchKey", matchKey);
// console.log("matchValue", matchValue);
// console.log("dirs", dirs);
done(
getFSCompletions({
currentWord,
Expand Down

0 comments on commit d982c34

Please sign in to comment.