///<reference path="../../.d.ts"/>
"use strict";

export class ProjectPropertyCommandBase {
	protected projectSchema: any;
	public $project: Project.IProject;

	constructor(private $staticConfig: IStaticConfig,
		private $injector: IInjector) {
		this.$staticConfig.triggerJsonSchemaValidation = false;
		this.$project = this.$injector.resolve("project");
		if (this.$project.projectData) {
			this.projectSchema = this.$project.getProjectSchema().wait();
		}
	}

	public get completionData(): string[] {
		let parseResult = /prop[ ]+([^ ]+) ([^ ]*)/.exec(process.argv.join(" "));
		if (parseResult) {
			let propName = parseResult[2];
			if (this.projectSchema[propName]) {
				let range = this.projectSchema[propName].range;
				if (range) {
					if (!_.isArray(range)) {
						range = _.map(range, (value:{ input: string }, key:string) => {
							return value.input || key;
						});
					}
					return range;
				}
			} else {
				return _.keys(this.projectSchema);
			}
		}

		return null;
	}
}

///<reference path="../../.d.ts"/>
"use strict";

export class ProjectPropertyCommandBase {
	protected projectSchema: any;
	public $project: Project.IProject;

	constructor(private $staticConfig: IStaticConfig,
		private $injector: IInjector) {
		this.$staticConfig.triggerJsonSchemaValidation = false;
		this.$project = this.$injector.resolve("project");
		if (this.$project.projectData) {
			this.projectSchema = this.$project.getProjectSchema().wait();
		}
	}

	public get completionData(): string[] {
		let parseResult = /prop[ ]+([^ ]+) ([^ ]*)/.exec(process.argv.join(" "));
		if (parseResult) {
			let propName = parseResult[2];
			if (this.projectSchema[propName]) {
				let range = this.projectSchema[propName].range;
				if (range) {
					if (!_.isArray(range)) {
						range = _.map(range, (value:{ input: string }, key:string) => {
							return value.input || key;
						});
					}
					return range;
				}
			} else {
				let properties = _.keys(this.projectSchema);
				return properties.concat(properties.map(k => k.toLowerCase()));
			}
		}

		return null;
	}
}

Allow autocompletion of lowercased properties
Allow autocompletion of lowercased properties

In case user is using only lowercased values for properties, autocompletion is not working.
For example `appbuilder prop print core` is not autocompleted to coreplugins.
In fact the command will work with lowercased values, so enable using them.
Add lowercased values to the ones used for autocompletion.
With this change the above will work, but scenarios like `appbuilder prop print cOre` will not be autocompleted anyway.
