Skip to content

Commit

Permalink
Improve CLI arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
clintandrewhall committed Jan 11, 2024
1 parent 6ace3b1 commit 07e52e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
16 changes: 6 additions & 10 deletions packages/kbn-plugin-check/dependencies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,19 @@ export const checkDependencies = (flags: Flags, log: ToolingLog) => {
displayDependencyCheck(project, plugin, log);
};

const pluginName = flags.plugin && typeof flags.plugin === 'string' ? flags.plugin : null;
const teamName = flags.team && typeof flags.team === 'string' ? flags.team : null;
const pluginOrTeam = typeof flags.dependencies === 'string' ? flags.dependencies : undefined;

if ((!pluginName && !teamName) || (pluginName && teamName)) {
log.error(`Must specify plugin or team name.`);
if (!pluginOrTeam) {
return;
}

if (pluginName) {
checkPlugin(pluginName);
}

if (teamName) {
const plugins = findTeamPlugins(teamName);
if (pluginOrTeam.startsWith('@elastic/')) {
const plugins = findTeamPlugins(pluginOrTeam);

plugins.forEach((plugin) => {
checkPlugin(plugin.manifest.id);
});
} else {
checkPlugin(pluginOrTeam);
}
};
19 changes: 6 additions & 13 deletions packages/kbn-plugin-check/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ export const runPluginCheckCli = () => {
}

if (flags.dependencies) {
if ((!flags.plugin && !flags.team) || (flags.plugin && flags.team)) {
throw new Error(
'Either --plugin or --team must or may be specified when checking dependencies.'
);
}

checkDependencies(flags, log);
}

Expand All @@ -48,14 +42,13 @@ export const runPluginCheckCli = () => {
defaultLevel: 'info',
},
flags: {
boolean: ['dependencies', 'rank'],
string: ['plugin', 'team', 'dependents'],
boolean: ['rank'],
string: ['dependencies', 'dependents'],
help: `
--rank Display plugins as a ranked list of usage.
--dependents [plugin] Display plugins that depend on a given plugin.
--dependencies Check plugin dependencies.
--plugin [plugin] The plugin to check.
--team [team] Check all plugins owned by a given team.
--rank Display plugins as a ranked list of usage.
--dependents [plugin] Display plugins that depend on a given plugin.
--dependencies [plugin] Check plugin dependencies for a single plugin.
--dependencies [team] Check dependencies for all plugins owned by a team.
`,
},
}
Expand Down

0 comments on commit 07e52e6

Please sign in to comment.