Make 'source' a positional argument in extensions install and set flag to true (#7807)

This commit is contained in:
christine betts
2025-09-05 11:44:41 -07:00
committed by GitHub
parent a7bfab4d96
commit 69da43eb70
9 changed files with 52 additions and 73 deletions
@@ -17,14 +17,14 @@ describe('extensions install command', () => {
it('should fail if no source is provided', () => {
const validationParser = yargs([]).command(installCommand).fail(false);
expect(() => validationParser.parse('install')).toThrow(
'Either --source or --path must be provided.',
'Either source or --path must be provided.',
);
});
it('should fail if both git source and local path are provided', () => {
const validationParser = yargs([]).command(installCommand).fail(false);
expect(() =>
validationParser.parse('install --source some-url --path /some/path'),
validationParser.parse('install some-url --path /some/path'),
).toThrow('Arguments source and path are mutually exclusive');
});
});
@@ -65,12 +65,12 @@ export async function handleInstall(args: InstallArgs) {
}
export const installCommand: CommandModule = {
command: 'install [--source | --path ]',
command: 'install [source]',
describe:
'Installs an extension from a git repository (URL or "org/repo") or a local path.',
builder: (yargs) =>
yargs
.option('source', {
.positional('source', {
describe: 'The git URL or "org/repo" of the extension to install.',
type: 'string',
})
@@ -81,7 +81,7 @@ export const installCommand: CommandModule = {
.conflicts('source', 'path')
.check((argv) => {
if (!argv.source && !argv.path) {
throw new Error('Either --source or --path must be provided.');
throw new Error('Either source or --path must be provided.');
}
return true;
}),