diff --git a/src/main.js b/src/main.js index c93c116..ee09762 100644 --- a/src/main.js +++ b/src/main.js @@ -9,6 +9,7 @@ import { uploadFile, downloadFile, showLocalFiles } from './handlers/fileHandler import { checkCodexInstallation, installCodex, uninstallCodex } from './handlers/installationHandlers.js'; import { runCodex, checkNodeStatus } from './handlers/nodeHandlers.js'; import { showInfoMessage } from './utils/messages.js'; +import { getAppDataDir } from "./utils/appdata.js"; async function showNavigationMenu() { console.log('\n') @@ -49,6 +50,10 @@ function handleExit() { process.exit(0); } +function getWorkingDir(commandArgs) { + +} + export async function main() { const commandArgs = parseCommandLineArgs(); if (commandArgs) { @@ -69,6 +74,7 @@ export async function main() { try { while (true) { console.log('\n' + chalk.cyanBright(ASCII_ART)); + console.log(showInfoMessage(`Working directory: ${getAppDataDir()}`)); const { choice } = await inquirer.prompt([ { diff --git a/src/utils/appdata.js b/src/utils/appdata.js new file mode 100644 index 0000000..24b1d99 --- /dev/null +++ b/src/utils/appdata.js @@ -0,0 +1,28 @@ +import path from 'path'; + +export function getAppDataDir() { + return appData("codex-cli"); +} + +function appData(...app) { + let appData; + if (process.platform === 'win32') { + appData = path.join(process.env.APPDATA, ...app); + } else if (process.platform === 'darwin') { + appData = path.join(process.env.HOME, 'Library', 'Application Support', ...app); + } else { + appData = path.join(process.env.HOME, ...prependDot(...app)); + } + return appData; +} + +function prependDot(...app) { + return app.map((item, i) => { + if (i === 0) { + return `.${item}`; + } else { + return item; + } + }); +} +