Skip to content

Commit

Permalink
feat!: Restructure config commands to match design guidelines (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-yeager authored Nov 22, 2024
1 parent c34a566 commit 3d882c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
5 changes: 1 addition & 4 deletions commands/__tests__/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
import yargs from 'yargs';
import set from '../config/set';
import { addAccountOptions, addConfigOptions } from '../../lib/commonOpts';
import { addConfigOptions } from '../../lib/commonOpts';

jest.mock('yargs');
jest.mock('../config/set');
Expand Down Expand Up @@ -40,9 +40,6 @@ describe('commands/config', () => {

expect(addConfigOptions).toHaveBeenCalledTimes(1);
expect(addConfigOptions).toHaveBeenCalledWith(yargs);

expect(addAccountOptions).toHaveBeenCalledTimes(1);
expect(addAccountOptions).toHaveBeenCalledWith(yargs);
});

it('should add the correct number of sub commands', () => {
Expand Down
5 changes: 2 additions & 3 deletions commands/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-nocheck
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
const { addConfigOptions } = require('../lib/commonOpts');

const { i18n } = require('../lib/lang');
const set = require('./config/set');

Expand All @@ -10,8 +11,6 @@ exports.describe = i18n(`${i18nKey}.describe`);

exports.builder = yargs => {
addConfigOptions(yargs);
addAccountOptions(yargs);

yargs.command(set).demandCommand(1, '');

return yargs;
Expand Down
14 changes: 5 additions & 9 deletions commands/config/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,23 @@ exports.handler = async options => {
exports.builder = yargs => {
yargs
.options({
defaultMode: {
'default-mode': {
describe: i18n(`${i18nKey}.options.defaultMode.describe`),
type: 'string',
},
allowUsageTracking: {
'allow-usage-tracking': {
describe: i18n(`${i18nKey}.options.allowUsageTracking.describe`),
type: 'boolean',
},
httpTimeout: {
'http-timeout': {
describe: i18n(`${i18nKey}.options.httpTimeout.describe`),
type: 'string',
},
})
.conflicts('defaultMode', 'allowUsageTracking')
.conflicts('defaultMode', 'httpTimeout')
.conflicts('allowUsageTracking', 'httpTimeout');

yargs.example([['$0 config set', i18n(`${i18nKey}.examples.default`)]]);

//TODO remove this when "hs accounts use" is fully rolled out
yargs.strict(false);
.conflicts('allowUsageTracking', 'httpTimeout')
.example([['$0 config set', i18n(`${i18nKey}.examples.default`)]]);

return yargs;
};
4 changes: 2 additions & 2 deletions lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ en:
success:
configFileUpdated: "Account \"{{ accountName }}\" updated in {{ configFilename }} using \"{{ authType }}\""
config:
describe: "Commands for working with the config file."
describe: "Commands for managing the CLI config file."
subcommands:
set:
describe: "Commands for modifying the CLI configuration"
describe: "Commands for modifying the CLI configuration."
promptMessage: "Select a config option to update"
examples:
default: "Opens a prompt to select a config item to modify"
Expand Down

0 comments on commit 3d882c9

Please sign in to comment.