Plugin name list

Summary:
Adds an argument to the headless Flipper to print the list of available plugins. Added `--list-plugins`.

Currently the startFlipper function is not scalable enough to add new arguments and its implementation. I am planning to tackle this with the list of Actions which will be closure. So adding a new argument with its implementation will be just appending a closure at the correct location in an array. Will work on that in the later diff stacked on the current one.

Reviewed By: jknoxville

Differential Revision: D15789778

fbshipit-source-id: 91ba472617d593c3490bb932590a06d83597cba7
This commit is contained in:
Pritesh Nandgaonkar
2019-06-17 06:14:49 -07:00
committed by Facebook Github Bot
parent 198841d1d7
commit e5294d34f0
5 changed files with 105 additions and 5 deletions

View File

@@ -7,6 +7,9 @@
import type BaseDevice from '../devices/BaseDevice.js';
import {FlipperDevicePlugin, FlipperPlugin} from '../plugin.js';
import type {State as PluginStatesState} from '../reducers/pluginStates.js';
import {pluginsClassMap} from './exportData.js';
import type {State as PluginsState} from '../reducers/plugins.js';
import type {PluginDefinition} from '../dispatcher/plugins';
export function getPluginKey(
selectedApp: ?string,
@@ -41,3 +44,26 @@ export function getPersistedState<PersistedState>(
};
return persistedState;
}
export function getActivePluginNames(plugins: PluginsState): Array<string> {
let pluginsMap: Map<
string,
Class<FlipperDevicePlugin<> | FlipperPlugin<>>,
> = pluginsClassMap(plugins);
let arr: Array<PluginDefinition> = plugins.disabledPlugins.concat(
plugins.gatekeepedPlugins,
);
arr.forEach((plugin: PluginDefinition) => {
if (pluginsMap.has(plugin.name)) {
pluginsMap.delete(plugin.name);
}
});
plugins.failedPlugins.forEach((plugin: [PluginDefinition, string]) => {
if (plugin[0] && plugin[0].name && pluginsMap.has(plugin[0].name)) {
pluginsMap.delete(plugin[0].name);
}
});
return [...pluginsMap.keys()];
}