-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roy Razon
committed
Oct 18, 2023
1 parent
7ace423
commit b30421f
Showing
3 changed files
with
26 additions
and
15 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
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 |
---|---|---|
@@ -1,27 +1,34 @@ | ||
import { profileStore } from '@preevy/core' | ||
import { ux } from '@oclif/core' | ||
import { | ||
DriverName, | ||
} from '../../../drivers' | ||
import { EOL } from 'os' | ||
import chalk from 'chalk' | ||
import { DriverName } from '../../../drivers' | ||
import ProfileCommand from '../../../profile-command' | ||
|
||
// eslint-disable-next-line no-use-before-define | ||
export default class ViewProfileConfig extends ProfileCommand<typeof ViewProfileConfig> { | ||
static description = 'View profile configuration' | ||
|
||
static strict = false | ||
|
||
static enableJsonFlag = true | ||
|
||
async run(): Promise<void> { | ||
async run(): Promise<unknown> { | ||
const pStore = profileStore(this.store) | ||
const driver = this.profile.driver as DriverName | ||
const origin = await pStore.defaultFlags(driver) | ||
const config = await pStore.defaultFlags(driver) | ||
if (!driver) { | ||
ux.info('Missing driver configuration in profile, use preevy profile config update --driver flag to set the desired machine driver') | ||
return | ||
ux.error([ | ||
'Missing driver configuration in profile.', | ||
`Run ${chalk.bold(`${this.config.bin} profile config update --driver <driver>`)} to set the desired machine driver`, | ||
].join(EOL)) | ||
} | ||
if (this.flags.json) { | ||
return { driver, defaultFlags: config } | ||
} | ||
ux.info(`Current configuration for driver ${chalk.bold(driver)}:`) | ||
if (Object.keys(config).length) { | ||
ux.styledObject(config) | ||
} else { | ||
ux.info('(empty)') | ||
} | ||
ux.info(`Current configuration for ${driver}:`) | ||
ux.styledObject(origin) | ||
return undefined | ||
} | ||
} |
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