-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- shows current drive name, provider and path - also displays list of drives
- Loading branch information
1 parent
d05ea92
commit 3610074
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Command to move into a folder | ||
|
||
// Use the chalk library to write colourful text | ||
import Chalk from 'chalk' | ||
|
||
// Import all methods from config and utils | ||
import * as Config from '../utils/config.util' | ||
import * as FsUtils from '../utils/fs.util' | ||
// Import the print statement | ||
import { print } from '../utils/general.util' | ||
// Import the logger | ||
import Logger from '../utils/logger.util' | ||
|
||
// The cd command | ||
export const run = async (args: string[]): Promise<void> => { | ||
Logger.debug(`command.cd.run: cd called with args: ${args}`) | ||
|
||
// Print out the current drive name, type and path | ||
const currentDrive = Config.get('currentDrive') as string | ||
|
||
if (!currentDrive) { | ||
throw new Error(`Invalid current drive name`) | ||
} | ||
|
||
print( | ||
Chalk.yellow( | ||
`In drive ${Chalk.keyword('orange')( | ||
currentDrive, | ||
)} (${Chalk.keyword('orange')( | ||
Config.get(`drives.${currentDrive}.provider`), | ||
)}); current path: ${Chalk.keyword('orange')( | ||
Config.get(`drives.${currentDrive}.path`) || '/', | ||
)}`, | ||
), | ||
) | ||
|
||
// Also print a list of all drives | ||
const drives = Config.get(`drives`) as Record<string, any> | ||
|
||
print(Chalk.yellow('\nList of drives:')) | ||
for (const drive of Object.keys(drives)) { | ||
print( | ||
Chalk.yellow( | ||
`- ${Chalk.keyword('orange')(drive)} (${Chalk.keyword('orange')( | ||
Config.get(`drives.${drive}.provider`), | ||
)}); current path: ${Chalk.keyword('orange')( | ||
Config.get(`drives.${drive}.path`) || '/', | ||
)}`, | ||
), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters