Skip to content

Commit 9451640

Browse files
committed
fix: print note when attempting to use non-interactive commands in interactive mode
1 parent a59d9c4 commit 9451640

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ export class App {
500500
})
501501
if (exitWithError) throw exitCode1Error
502502
}
503+
// keep list of commands updated at commands.ts/nonInteractiveCommands
503504
}
504505
}
505506

src/featureInterfaces/fs/commands.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ export const fsCommands: Command[] = [
141141
},
142142
]
143143

144+
/**
145+
* All available non-filesystem commands, for interactive mode unknown command handling.
146+
*/
147+
export const nonInteractiveCommands = ["version", "canary", "install", "logout", "export-auth-config", "export-api-key", "webdav", "webdav-proxy", "s3", "sync", "trash", "link", "links", "mount", "export-notes"]
148+
144149
/**
145150
* Splits a command input into segments, while respecting quotes.
146151
* Example: `'cd "folder name"'` returns `['cd', '"folder name"']`.

src/featureInterfaces/fs/fs.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { directorySize, doNothing, getItemPaths, hashFile } from "../../util/uti
44
import { CloudPath } from "../../util/cloudPath"
55
import * as fsModule from "node:fs"
66
import open from "open"
7-
import { fsCommands } from "./commands"
7+
import { fsCommands, nonInteractiveCommands } from "./commands"
88
import { HelpPage } from "../../interface/helpPage"
99
import { displayTransferProgressBar, formatBytes, formatTable, formatTimestamp } from "../../interface/util"
1010
import arg from "arg"
@@ -55,7 +55,11 @@ export class FS {
5555
const command = fsCommands.find(command => [command.cmd, ...command.aliases].includes(cmd))
5656

5757
if (command === undefined) {
58-
this.app.outErr(`Unknown command: ${cmd}`)
58+
if (nonInteractiveCommands.includes(cmd)) {
59+
this.app.outErr(`Unknown command: ${cmd}. (It is not available in interactive mode, use \`filen ${cmd}\` instead)`)
60+
} else {
61+
this.app.outErr(`Unknown command: ${cmd}`)
62+
}
5963
return {}
6064
}
6165

0 commit comments

Comments
 (0)