{"size": 1620, "ext": "js", "max_stars_repo_path": "src/cli/commands/info.js", "max_stars_repo_name": "cb1kenobi/appcd-plugin-titanium", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/cli/commands/info.js", "max_issues_repo_name": "cb1kenobi/appcd-plugin-titanium", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/cli/commands/info.js", "max_forks_repo_name": "cb1kenobi/appcd-plugin-titanium", "max_forks_repo_forks_event_min_datetime": "2019-08-14T21:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-13T13:25:42.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 24.5454545455, "max_line_length": 117, "alphanum_fraction": 0.5987654321}
import android from '../info/android';
import ios from '../info/ios';
import jdk from '../info/jdk';
import os from '../info/os';
import titanium from '../info/titanium';
import windows from '../info/windows';

const types = {
	android,
	ios,
	jdk,
	os,
	titanium,
	windows
};

export default {
	async action({ console, argv, data }) {
		const selectedTypes = new Set(argv.types.toLowerCase().split(','));
		const results = {};

		// load the data
		await Promise.all(
			Object
				.keys(types)
				.filter(type => typeof types[type].fetch === 'function' && (selectedTypes.has('all') || selectedTypes.has(type)))
				.sort()
				.map(async type => {
					results[type] = null;
					if (typeof types[type].fetch === 'function') {
						try {
							results[type] = await types[type].fetch(data);
						} catch (err) {
							results[type] = { error: err.stack };
						}
					}
				})
		);

		if (argv.json || argv.output === 'json') {
			console.log(JSON.stringify(results, null, '  '));
		} else {
			for (const type of Object.keys(results)) {
				await types[type].render(console, results[type]);
			}
		}
	},
	args: [
		{
			name: 'filter...',
			description: 'Information types to display; you may select one or more'
		}
	],
	desc: 'Display development environment information.',
	options: {
		'--json': 'Output info as JSON',
		'-o, --output [forma]>': { hidden: true },
		'-t, --types [types]': {
			default: 'all',
			desc: 'Information types to display; you may select one or more',
			hidden: true,
			values: [ 'all', ...Object.keys(types).filter(type => typeof types[type].fetch === 'function') ]
		}
	}
};
